skip to Main Content

Facebook comments component load same JavaScripts many times and slows our page with 1.2+seconds sometimes load for 29sec

Please help.

the script is in the bottom of the HTML source, we get it from Facebook developer API

http://www.247polls.com/polls/should-marijuana-be-legalized/

enter image description here

2

Answers


  1. FB.XFBML.parse();
    

    Will load your comments even if the page loading has not been completed:

    <script>
        window.fbAsyncInit = function () {
            FB.init({appId: 'YOUR-APP-ID', version: 2.4, xfbml: true});
    
            if (typeof facebookInit == 'function') {
                facebookInit();
            }
        };
    
        (function () {
            var e = document.createElement('script');
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            e.async = true;
            document.getElementById('fb-root').appendChild(e);
        }());
    
    
        function facebookInit() {
            console.log('Loading comments...');
            FB.XFBML.parse();
        }
    </script>
    

    Another thing to improve the speed is limiting the count of comments to show with num_posts to 5.

    Keep rocking!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search