Created
April 15, 2014 01:41
-
-
Save sonyseng/10695142 to your computer and use it in GitHub Desktop.
Load some javascript from a CDN. Doesn't work if the response header includes Content-Security-Policy prohibiting such actions. (i.e. github)
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
(function (url, onLoad) { | |
var script = document.createElement('script'); | |
script.addEventListener('load', onLoad); | |
script.src = url; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
}('https://cdnjs.cloudflare.com/ajax/libs/q.js/0.9.2/q.js', function () { | |
// Load the Q promises library dynamically and print out the object | |
console.log(Q); | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment