Skip to content

Instantly share code, notes, and snippets.

@hendriono
Forked from ngryman/snippet.js
Created June 15, 2013 18:38
Show Gist options
  • Save hendriono/5789103 to your computer and use it in GitHub Desktop.
Save hendriono/5789103 to your computer and use it in GitHub Desktop.
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(d, u) {
var s = d.scripts[0],
i = u.length, g;
while (i--) {
g = d.createElement('script');
g.src = '//' + u[i] + '.js';
s.parentNode.insertBefore(g, s);
}
}(document, [
// Google Analytics
'google-analytics.com/ga',
// Google+ button
'apis.google.com/js/plusone',
// Facebook SDK
'connect.facebook.net/en_US/all',
// Twitter SDK
'platform.twitter.com/widgets'
]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment