Facebook SPOF - how to prevent?

Facebook was/is down for > last 1 hour… it caused problems for my site


I use iframe for the like/recommend widget. On my site, the story pages are cached on disk for months, so for now i replaced the facebook url with a dummy blank html page (using substitute module in nginx) to mitigate the SPOF until Facebook fixes their shit.

The question is… how to prevent this in the future? Any hacks around where i can load iframes in a manner such that their failure doesnt hold back the document.onload() from firing?

PS: PLS don’t suggest getting rid of the Facebook widget . it gets me traffic :slight_smile:

Can you populate the Facebook widget at onload? That would certainly do it (though it would delay rendering of the widget) :slight_smile:

aha… thanks… makes sense… i don’t mind the 3 - 5 second delay in the facebook widget being populated (i think - would be worth doing ab testing on it)…

meaning something like this?

<div id="facebookwidget"></div>

and after onload

document.getElementById('facebookwidget').innerHTML = '<iframe src......>';

or is there a better way?

on a side note… facebook should use a cdn served static file for the base iframe page… and then the iframe should load the dynamic stuff via ajax call.

That would probably work but might be cleaner to include the empty iFrame and then just set the src as part of the onload: http://www.cryer.co.uk/resources/javascript/script4.htm#LoadingOtherFilesUsingIFRAME

Realized this issue is bigger than i suspected
see http://www.webpagetest.org/result/100923_b36fcc22bde3c8f714cc015dcb062362/1/details/

I have the tweet button on all my pages also (loading them async but not deferring them) . Since china blocks twitter, so all pages which uses the tweet button(or facebook like widget) will fail. Even worse consequences if they load it synchronously as the docs suggest.

Deferring 3rd party stuff is a workaround, but not a nice one… In some cases the user may already finish “scanning” the story before the sharing widgets come to life…

China is not a major target for me, but each click counts. Moreover, if universities/corporate networks blocks these sites, our pages would also suffer similarly… Need to find some better solution to these issues than deferring their loading…

Sidenote: TribalFusion ad network also seems to be blocked in China…

I guess it largely depends on what your page does. If you don’t have any code attached to onLoad then loading the widgets asynchronously is probably the best way to do it because they will load quickly in the normal case and not block any of your actual page functionality (though the user will see the page “loading” until everything fails).

If you do have logic you care about attached to onload then things get trickier because these failures actually push that out and you have a SPOF again (just not for the page content). Would be great if there was a way to async load during the page load and make that content not block the onload but I’m not aware of any reliable ways to do it.

I hadn’t thought about the pathological case of things being broken because of the great firewall but that could actually be a pretty big deal for a lot of the web.

Ok… found a solution for iframes


Does not need to be differed to after onload.
Does not block onload event