Skip to content

Instantly share code, notes, and snippets.

@azizmb
Created July 18, 2012 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azizmb/3134325 to your computer and use it in GitHub Desktop.
Save azizmb/3134325 to your computer and use it in GitHub Desktop.
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