Created
June 3, 2016 15:53
-
-
Save kidker/37d98d7ab5620b89fdd1152273114926 to your computer and use it in GitHub Desktop.
Async function with callback
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
down vote | |
accepted | |
Thanks RASG for http://stackoverflow.com/a/3211647/982924 | |
Async function with callback: | |
function async(u, c) { | |
var d = document, t = 'script', | |
o = d.createElement(t), | |
s = d.getElementsByTagName(t)[0]; | |
o.src = '//' + u; | |
if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); } | |
s.parentNode.insertBefore(o, s); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment