Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Loading multiple 3rd party widgets asynchronously
(function() {
var script,
scripts = document.getElementsByTagName('script')[0];
function load(url) {
script = document.createElement('script');
script.async = true;
script.src = url;
scripts.parentNode.insertBefore(script, scripts);
}
load('//apis.google.com/js/plusone.js');
load('//platform.twitter.com/widgets.js');
load('//s.widgetsite.com/widget.js');
}());
@mingyun
Copy link

mingyun commented Nov 9, 2013

good

@3runoDesign
Copy link

3runoDesign commented Dec 20, 2013

goood

@kimmykuang
Copy link

kimmykuang commented Dec 11, 2014

i think pass 'document' into scope is better

@fer-ri
Copy link

fer-ri commented May 15, 2015

Nice 👍

@PokemonAshLovesMyTurkeyAndILikeYouTwo

ty babe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment