Skip to content

Instantly share code, notes, and snippets.

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);
Copy link

thefrontender commented Mar 21, 2013

@harry1989 Both are valid Javascript. But if you want an opinionated answer, try Crockford

Copy link

jswebschmiede commented Mar 27, 2013

i use a window onload version. look

Copy link

coljung commented Mar 30, 2013

Similar to this one: , although i find that one much better.

Copy link

franklinjavier commented May 13, 2013

How about to pass the "document" as parameter into scope?

Copy link

mingyun commented Nov 9, 2013


Copy link

3runoDesign commented Dec 20, 2013


Copy link

kimmykuang commented Dec 11, 2014

i think pass 'document' into scope is better

Copy link

fer-ri commented May 15, 2015

Nice 👍


ty babe

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