Created
February 11, 2012 16:59
-
-
Save stellarcowboy/1802252 to your computer and use it in GitHub Desktop.
Conditionally load Facebook social plugin based on screen width
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
<div id="fb-catcher"></div> | |
<script> | |
if (document.documentElement.clientWidth >= 600) { | |
document.getElementById('fb-catcher').innerHTML='<div id="fb-root"></div>'; | |
} | |
(function(d, s, id) { | |
var js, fjs = d.getElementsByTagName(s)[0]; | |
if (d.getElementById(id)) return; | |
js = d.createElement(s); js.id = id; | |
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=xxxxxxxxxxxxx"; | |
fjs.parentNode.insertBefore(js, fjs); | |
}(document, 'script', 'facebook-jssdk')); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment