Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Created May 4, 2010 13:13
Show Gist options
  • Save phiggins42/389394 to your computer and use it in GitHub Desktop.
Save phiggins42/389394 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Do Nothing.</title>
</head>
<body>
<script>
(function(){
// some boilerplate load-a-script-code
var d = document, head = d.getElementsByTagName("head")[0],
s = d.createElement("script");
s.src = "http://o.aolcdn.com/dojo/1.4/dojo/dojo.xd.js";
s.onload = s.onreadystatechange = function(e){
if(e && e.type == "load" || /loaded|complete/.test(s.readyState)){
s.onload = s.onreadystatechange = null;
dojo.ready(init); // ensure DOM ready too
}
}
head.appendChild(s);
var init = function(){
// stuff to do when dojo is loaded (and the DOM, too)
console.log("We're cool.");
}
})();
</script>
</body>
</html>
@mathiasbynens
Copy link

Change head = d.getElementsByTagName('head')[0] into head = d.head || d.getElementsByTagName('head')[0] for added HTML5 buzzwordness. Or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment