Last active
October 4, 2024 14:04
-
Star
(184)
You must be signed in to star a gist -
Fork
(48)
You must be signed in to fork a gist
-
-
Save zenorocha/5161860 to your computer and use it in GitHub Desktop.
Loading multiple 3rd party widgets asynchronously
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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'); | |
}()); |
i use a window onload version. look https://gist.github.com/jswebschmiede/3660918
Similar to this one: https://gist.github.com/necolas/1025811 , although i find that one much better.
How about to pass the "document" as parameter into scope?
good
goood
i think pass 'document' into scope is better
Nice 👍
ty babe
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@harry1989 Both are valid Javascript. But if you want an opinionated answer, try Crockford http://www.youtube.com/watch?v=taaEzHI9xyY&feature=youtu.be#t=33m39s