Skip to content

Instantly share code, notes, and snippets.

@palicko
Created December 17, 2016 16:27
Show Gist options
  • Save palicko/0dcdcc47309411296cad9dbbbb5d11fb to your computer and use it in GitHub Desktop.
Save palicko/0dcdcc47309411296cad9dbbbb5d11fb to your computer and use it in GitHub Desktop.
Load social scripts after page is loaded
(function(w, d, s) {
function go(){
var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id) {
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.src = url; js.id = id;
fjs.parentNode.insertBefore(js, fjs);
};
load('//connect.facebook.net/en_US/all.js#appId=272697932759946&xfbml=1', 'fbjssdk');
load('https://apis.google.com/js/plusone.js', 'gplus1js');
load('//platform.twitter.com/widgets.js', 'tweetjs');
}
if (w.addEventListener) { w.addEventListener("load", go, false); }
else if (w.attachEvent) { w.attachEvent("onload",go); }
}(window, document, 'script'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment