Like what you read? Share for your friends!

Everybody is fascinated with whole idea of Facebook Page Plugin. Even I have published two posts related to that. Anyways the Facebook script which Face book developers provided makes the website loading a bit slow.
The script which users get from the the Facebook Plugin page is,

<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.3&appId=630535786999761";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

What is issues with this script?


This script is synchronous and takes a while to load.

This script affects the loading of other components of your website.

The script delays overall loading speed of their website.

In the world of fast and furious, this will create a step back for your website/blog.

Also read: Adding Page Plugin gadget of Facebook to Blog Spot Blog/Website Templates

SOLUTION


The Facebook Plugin Asynchronous Script works the same as the above code. It works charmingly if i may say. It loads fast and don't hinder downloading of other gadgets.

Just copy the below code and Replace your appID.

<div id='fb-root'/>
<script>
window.fbAsyncInit = function() {
    FB.init({
      appId      : &#39;630535786999761&#39;, // App ID
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });
    // Additional initialization code here
  };
  // Load the SDK Asynchronously
  (function(d){
     var js, id = &#39;facebook-jssdk&#39;, ref = d.getElementsByTagName(&#39;script&#39;)[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement(&#39;script&#39;); js.id = id; js.async = true;
     js.src = &quot;//connect.facebook.net/en_US/all.js&quot;;
     ref.parentNode.insertBefore(js, ref);
   }(document));
</script>

Paste the copied code and paste it inside the blogger template. Reload your website and check the speed.

I would be glad if you could Follow my posts on Facebook.

Also read: Solved: Face Book Page Plugin entity "version" must end with the ';' delimiter error


Comments || >

Subscribe via Email

Don't Miss Any Updates, Stay Connected!.

We respect your privacy and will never share your email address with any person or organisation.