How to Implement Facebook JavaScript SDK in Your Blogger Blog


Have you ever heard of Facebook JavaScript SDK? May be or may be not. 
But if you ever try out Facebook social plugins on your website 
or blog, then you may have come across with this name. Facebook 
plugins need to communicate with Facebook servers whenever they 
rendering and deal with user actions. Due to this 
phenomenon Facebook uses JavaScript functionality with 
their plugins itself. But JavaScript SDK provides enormous 
features like ensuring appropriate plugin being 
rendered on your blog, authenticating users, sharing and more.

If you are using XFBML version of Facebook plugins in your blog,
then you have to include Facebook JavaScript SDK to enhance 
the performance and functionality of your plugins. However you 
can use JavaScript SDK for different purposes. If you are 
willing to render only social plugins, then you can implement 
Basic JavaScript SDK on your blog. Else if you wish to 
access more advanced features such as Authentication, Server 
side API calls you need an application ID to initialize 
JavaScript SDK. For that purpose you have to implement 
JavaScript SDK with Application ID. So to make use of 
advanced features using JavaScript SDK, you need to be a 
Facebook member. However here you can learn how to 
implement Facebook JavaScript SDK in your blog 
eventhough you are a Facebook member or not.

Steps:

1. Go to Blogger Dashboard.

2. Click on your Blog Title.

3. Navigate to Template tab.

Note: Before editing your template, you may want to save 
a copy of it. 


4. Click Edit HTML button underneath your blog preview.

5. Click Proceed button to continue.

6. Tick on, Expand Widget Templates option.

7. Now you are ready to add Asynchronous JavaScript SDK 
which is most efficient than Standard JavaScript SDK. 
Simply  it ensures faster page loading. But as a 
prerequisite for Asynchronous JavaScript SDK 
(and Facebook plugins based on XFBML), you have 
to add XML namespace attribute below to your root html tag.

xmlns:fb="http://www.facebook.com/2008/fbml" 
xmlns:og="http://ogp.me/ns#"

i.e: <html xmlns="...." 
xmlns:fb="http://www.facebook.com/2008/fbml" 
xmlns:og="http://ogp.me/ns#" ......

8. Now select your preferred JavaScript SDK version 
and add it just after <body> tag.

Note: body tag may contain some other attributes too. 
So when you search for body tag, search <body keyword.

Basic JavaScript SDK

You can use this version of JavaScript SDK if you are 
not seeking for advanced features. If you just need to 
render only Facebook social plugins, this will be enough for you.

<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/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


JavaScript SDK with Application ID

This version of JavaScript SDK can be used to 
access more advanced features.

Note: To implement this version of JavaScript SDK, 
you need an Application ID to use with. 

<div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: '[Your Application ID]', 
status: true, cookie: true, xfbml: true});
  };

  (function() {
        var e = document.createElement('script');
        e.type = 'text/javascript';
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
      }());
</script>


Color Indication Information

   - Your Application ID

Specify your Facebook application ID here.
Get Free Updates:
*Please click on the confirmation link sent in your Spam folder of Email*