Created
March 14, 2013 19:42
JavaScript - Load multiple 3rd party widgets asyncronously.
This file contains hidden or 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
var script, | |
scripts = document.getElementsByTagName('script')[0], | |
scriptList = { | |
'plusone' : '//apis.google.com/js/plusone.js', | |
'twitter' : '//platform.twitter.com/widgets.js', | |
'someother': '//s.widgetsite.com/widget.js' | |
}; | |
for (var id in scriptList) { | |
script = document.createElement('script'); | |
script.async = true; | |
script.src = scriptList[id]; | |
scripts.parentNode.insertBefore(script, scripts); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment