Current time: 06-06-2020, 04:11 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Does configuring a SPOF in WebPagetest consider Javascript async feature?
12-04-2015, 11:57 PM
Post: #4
RE: Does configuring a SPOF in WebPagetest consider Javascript async feature?
Patrick,

we found the solution on the Facebook blog.

Instead of integration the Facebook script via an async script

Code:
(function () {
    var e = document.createElement('script');
    e.async = true;
    e.src = '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
} ());

we need to integrate it via an iframe to really have it run asynchronously and non render blocking.

Code:
(function() {
    var url = '//connect.facebook.net/en_US/all.js';
    var iframe = document.createElement('iframe');
    (iframe.frameElement || iframe).style.cssText = "width: 0; height: 0; border: 0";
    iframe.src = "javascript:false";
    document.getElementById('fb-root').appendChild(iframe);
    var doc = iframe.contentWindow.document;
    doc.open().write('<body onload="'+
               'window.inDapIF = true;' +
               'var js = document.createElement(\'script\');'+
               'js.src = \''+ url +'\';'+
               'document.body.appendChild(js);">');
    doc.close();
}());

Cheers,
Martin
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Does configuring a SPOF in WebPagetest consider Javascript async feature? - mbreest - 12-04-2015 11:57 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)