In my site I\'m using asynchronous loading of the Facebook JS SDK. To actually set it up I use the standard FB.init inside of window.fbAsyncInit function.
However the is
Sometimes the facebook api can call fbAsyncInit before your second fbAsyncInit has even started. This will fix that case:
if (window.fbAsyncInit.hasRun === true) {
setup(); // do something
} else {
var oldCB = window.fbAsyncInit;
window.fbAsyncInit = function () {
if (typeof oldCB === 'function') {
oldCB();
}
setup(); // do something
};
}