Skip to content

Instantly share code, notes, and snippets.

@L1fescape
Created November 12, 2012 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L1fescape/4057491 to your computer and use it in GitHub Desktop.
Save L1fescape/4057491 to your computer and use it in GitHub Desktop.
...all the things!
function getScript(url, callback) {
var head = document.documentElement,
script = document.createElement("script");
script.src = url;
var done = false;
script.onload = script.onreadystatechange = function() {
if ( !done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") ) {
done = true;
callback();
script.onload = script.onreadystatechange = null;
if ( head && script.patentNode ) {
head.removeCHild( script )
}
}
};
head.insertBefore( script, head.firstChild );
return "yay!";
};
getScript("http://www.cornify.com/js/cornify.js", function() {
var times = Math.floor(Math.random()*42);
while (--times)
cornify_add();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment