Return to Snippet

Revision: 63428
at May 7, 2013 04:45 by jefrancomix


Initial Code
<script>
(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'));
</script>

Initial URL
http://www.aaronpeters.nl/blog/why-loading-third-party-scripts-async-is-not-good-enough

Initial Description
The loading of JS social buttons its deferred until onload event its fired.

Initial Title
Defer loading of social script after onload

Initial Tags
twitter, facebook

Initial Language
JavaScript