How To Add Facebook JavaScript SDK To Blogger Themes Without XML Error

·

The Facebook JavaScript SDK is a rich set of client-side functionality for adding Social Plugins, Facebook Login and Graph API calls to desktop or mobile web. If you are a blogger, it will also enable you to use the Facebook like button and other Facebook social plugins on your blog.

Below is the default Facebook JavaScript SDK code, with the appid of my blog in it :

<div id=”fb-root”></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = “//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8&appId=150436614997987“;
  fjs.parentNode.insertBefore(js, fjs);
}(document, ‘script’, ‘facebook-jssdk’));</script>

Facebook requires that you add the code right after the opening <body> tag in your blog’s html to enable Facebook social plugins work on your blog.

Unfortunately, adding the code to your Blogger blog might throw some xml error. So, in this post, I want to share with you, how to add the Facebook JavaScript SDK to Blogger themes without throwing xml error.

Steps

Sign in to your Blogger dashboard, click on “Theme”

edit html in blogger themes

Click on “Edit HTML”

Use “CTRL F” to find the opening <body tag

Right below it, paste this code :

<div id=’fb-root’/>
&lt;script&gt;(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = &quot;//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v2.8&amp;appId=150436614997987&quot;;
  fjs.parentNode.insertBefore(js, fjs);
}(document, &#39;script&#39;, &#39;facebook-jssdk&#39;));&lt;/script&gt;

Change the highlighted appid to the application id of your blog.
Click “Save Theme”.

If saved successfully, it will look like this:

opening body tag in blogger theme

Recommended : How To Generate Facebook appid For Your Blog

If you don’t know your blog app id, use the code below:

<div id=’fb-root’/>
&lt;script&gt;(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = &quot;//connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v2.8&amp;appId=&quot;;
  fjs.parentNode.insertBefore(js, fjs);
}(document, &#39;script&#39;, &#39;facebook-jssdk&#39;));&lt;/script&gt;

Alternatively,

Add <div id=’fb-root’/> below the opening <body tag

Copy the script part of the default code and parse it.

After parsing it, paste it directly below the <div id=’fb-root’/>

Click “Save Theme

I hope this helps.

Please Share :

Like What You Read?

Sign Up to get similar articles delivered to your email inbox.

Leave a Reply

Your email address will not be published. Required fields are marked *

6 responses to “How To Add Facebook JavaScript SDK To Blogger Themes Without XML Error”

  1. olushollay adio Avatar

    nice one mr jide check me at
    http://www.nobleshub.com

  2. Ayeni Emmanuel Oluwasina Avatar

    nice write up. it really help my my blog. you can check it [url=www.eaglegist.com] HERE [/url]

  3. oluwa busiayomi Avatar

    please how do i get the application id of my blog

  4. Excellence Technology Avatar
    Excellence Technology

    Nice blog of javascript thanks for sharing this informative blog.

  5. Mcsowhustle Avatar
    Mcsowhustle

    I really appreciate your time I used this and it worked fine

Search

Copyright © 2025 | About | Advertise | Privacy Policy | Proudly powered by WordPress