Skip to content

Instantly share code, notes, and snippets.

@kidker
Created June 3, 2016 15:53
Show Gist options
  • Save kidker/37d98d7ab5620b89fdd1152273114926 to your computer and use it in GitHub Desktop.
Save kidker/37d98d7ab5620b89fdd1152273114926 to your computer and use it in GitHub Desktop.
Async function with callback
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