How can I block the download of Facebook on my website?

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

+3
source share
3 answers

You can download asynchronously as described in the update for the question. You get the app id from β€œcreate app” on facebook. (Google it ...)

+1
source

The loading of elements occurs from top to bottom in the code. If a very large resource is loaded on top of the code, it will delay the overall load. If you want to show your page earlier, put this button at the end of the code.

+1

, , ::)

: - FB, - JavaScript.

, , .

HTTP (JavaScript/CSS) , .

.htaccess

AddOutputFilter DEFLATE css js
ExpiresActive On
ExpiresByType application/x-javascript A2592000

, http://developer.yahoo.com/performance/rules.html

,

+1

Source: https://habr.com/ru/post/1789654/


All Articles