Last active
August 29, 2015 14:04
-
-
Save mjlescano/1d8310c84b53353ffa49 to your computer and use it in GitHub Desktop.
fbReady Function, to execute things when facebook asynchronously loaded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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