
James is not one for airy fairy advice and magical remedies, but works with cold, hard facts about why sleep can be hard and the importance of understanding what kind of sleepers we are to work out
…
See More
window.fbAsyncLoaded = false; window.fbAsyncPending = []; window.fbAsyncOnLoaded = function(callback) { if (window.fbAsyncLoaded) { callback(); } else { window.fbAsyncPending.push(callback); } };
// Register an event handler for Facebook init window.fbAsyncInit = function() { FB.init({ version: 'v8.0', appId: '215002133707', cookie: true, status: false, xfbml: false });
// Update state window.fbAsyncLoaded = true;
// Execute pending calls
for (var i = 0; i < window.fbAsyncPending.length; i++) {
window.fbAsyncPending[i]();
}
window.fbAsyncPending = [];
};
// Trick: monitor the "beforeload" event to check if someone else default
// prevented the loading of the facebook library
window.fbLoadPrevented = false;
function _checkFbPrevent(event) {
if (event.url && event.url.match('facebook')) {
document.removeEventListener("beforeload", _checkFbPrevent);
window.fbLoadPrevented = event.defaultPrevented;
}
}
if (document.addEventListener) {
document.addEventListener("beforeload", _checkFbPrevent, true);
}
// Load Facebook library
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));