Skip to content

Instantly share code, notes, and snippets.

@mjlescano
Last active August 29, 2015 14: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 mjlescano/1d8310c84b53353ffa49 to your computer and use it in GitHub Desktop.
Save mjlescano/1d8310c84b53353ffa49 to your computer and use it in GitHub Desktop.
fbReady Function, to execute things when facebook asynchronously loaded
;(function(){
// Function to have a list of functions to load on fbAsyncInit
var toLoad = []
window.fbReady = function(func){
window.FB ? func.call(window) : toLoad.push(func)
}
window.fbAsyncInit = function() {
FB.init({
appId: "#{FACEBOOK_API}",
status: true,
cookie: true,
xfbml: true
})
// Execute all the fbReady pending functions
toLoad.forEach(function(func){
func.call(window)
})
}
})();
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
<script src="fbReady.js"></script>
<script>
fbReady(function(){
FB.Canvas.setSize({ height: 1060 });
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment