Skip to content

Instantly share code, notes, and snippets.

@lsmith
Forked from isaacs/gist:157681
Created July 29, 2009 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lsmith/157854 to your computer and use it in GitHub Desktop.
Save lsmith/157854 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script>
// The signature is pure coincidence ;)
function L(U,C){var d=document,f='firstChild',r='readyState',h=d.documentElement[f],s=d.createElement('script'),m=s[r]:'onreadystatechange':'';s.type='text/javascript';s.src=U;s[m||'onload']=function(){if(!m||/loaded|complete/.test(s[r])){s[m]=null;C()}};h.insertBefore(s,h[f]);}
// async loading of javascript files, starting asap.
L("http://example.com/example.js",function () {
doSomething();
});
L("http://example.com/foo.js", function () {
fooSomeBar();
});
</script>
<title>Javascript loading example</title>
</head>
<body><p>When the JS loads, you'll see something being done, and some bar being fooed.</p></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment