I have added a Facebook button to my website. There, the delay when loading jscript is lower, and the rest of the page does not load until it is executed. Also, if I block facebook with my firewall, there is a very long delay before it gives up, and THEN the rest of my page will be displayed. How do I display my page first and then as a button? (I did this to find out what would happen if facebook had a problem.) In addition, when I load different pages, the facebook button as a button saves the reload (it is noticeably absent until the reload - 1/3 second.) The button is in one and the same place on each page, in the banner above. Other images do not reload - they are cached - and when you select another page, they become static. Is there any way to make the script be cached?
Here is the code:
<div style="position: absolute; top:20px; right:85px; width:70px; height:25px">
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like href="http://www.facebook.com/pages/somepage/somenum" layout="box_count" show_faces="false" width="50"></fb:like>
</div>
thank
UPDATE: I found this code to load all.js asynchronously:
"Another way is to load asynchronously so that it does not block the loading of other elements of your page:"
<div id="fb-root"></div><script>window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
But what is "your app id?" This code is from here http://www.mohammedarif.com/?p=180
source
share