Skip to content

Instantly share code, notes, and snippets.

@jiggliemon
Created August 16, 2011 18:33
Show Gist options
  • Save jiggliemon/1149798 to your computer and use it in GitHub Desktop.
Save jiggliemon/1149798 to your computer and use it in GitHub Desktop.
Facebook Init detector!
$(document).bind('FB.ready',function(){
console.log('FB is ready');
FB.api('/me',function(response){
console.log(response);
});
});
var _FB = {
count: 0
,interval : setInterval(function(){
try{
if(FB._session && (typeof FB._session !== 'undefined')){
clearInterval(_FB.interval);
$(document).trigger('FB.ready');
}
} catch(e){
if(_FB.count++ > 100) {
clearInterval(_FB.interval);
throw new Error('`FB` hasn\'t become available.');
}
}
},15)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment