Created
September 10, 2012 14:34
-
-
Save dingram/3691187 to your computer and use it in GitHub Desktop.
A minimalist way of including social JavaScript SDKs into a page. Includes Google Analytics, Twitter widgets, Facebook, and Google +1
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
window.___gcfg={lang:'en-GB'};var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-123456-9']);_gaq.push(['_trackPageview']);!function(d,s){var st=d.getElementsByTagName(s)[0],j=function(i,u){if(d.getElementById(i))return;var js=d.createElement(s);js.id=i;js.async=true;js.src=u;st.parentNode.insertBefore(js,st)};setTimeout(function(){j("twitter-wjs","//platform.twitter.com/widgets.js");j("facebook-jssdk","//connect.facebook.net/en_GB/all.js#xfbml=1");j("gplusone-sdk","https://apis.google.com/js/plusone.js")}, 0);j("ga-sdk",('https:'==d.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js')}(document,'script'); |
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
window.___gcfg = {lang: 'en-GB'}; | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-123456-9']); | |
_gaq.push(['_trackPageview']); | |
!function(d,s){ | |
var st = d.getElementsByTagName(s)[0], | |
j = function(id, url){ | |
if (d.getElementById(id)) return; | |
var js=d.createElement(s); | |
js.id=id; js.async=true; js.src=url; | |
st.parentNode.insertBefore(js,st); | |
}; | |
setTimeout(function(){ | |
j("twitter-wjs", "//platform.twitter.com/widgets.js"); | |
j("facebook-jssdk", "//connect.facebook.net/en_GB/all.js#xfbml=1"); | |
j("gplusone-sdk", "https://apis.google.com/js/plusone.js"); | |
}, 0); | |
// Keep Analytics on the main thread so there's no chance of losing analytic data from the user interacting with the page before the script loads | |
j("ga-sdk", ('https:'==d.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js'); | |
}(document,'script'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment