Created
August 24, 2012 21:29
-
-
Save patbenatar/3455814 to your computer and use it in GitHub Desktop.
Initialize Facebook JS SDK in Coffeescript
This file contains 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
# Important: this requires your Facebook App ID to be in data-id on #fb-root | |
window.fbAsyncInit = -> | |
FB.init | |
appId: document.getElementById("fb-root").getAttribute("data-id") | |
# Async load the JS SDK | |
id = "facebook-jssdk" | |
ref = document.getElementsByTagName("script")[0] | |
return if document.getElementById(id) | |
js = document.createElement("script") | |
js.id = id | |
js.async = true | |
js.src = "//connect.facebook.net/en_US/all.js" | |
ref.parentNode.insertBefore(js, ref) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment