Skip to content

Instantly share code, notes, and snippets.

@azizmb azizmb/fb_init.html
Created Jul 18, 2012

Embed
What would you like to do?
FB init
<div id="fb-root"></div>
<script>
var fbAppId = '< APP ID >';
(function(){
var fbInitFuncs = [];
var fbInitialized = false;
window.fbAsyncInit = function() {
fbInitialized = true;
FB.init({
appId : '< APP ID >',
status : true,
cookie : true,
xfbml : true
});
for(var i=0; i < fbInitFuncs.length; i++){
fbInitFuncs[i]();
}
};
window.onFbInit = function(func){
if(fbInitialized){
func();
}
else{
fbInitFuncs.push(func);
}
}
})();
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.