Get Scriipt
Insert any script into a page. Taken from Jquery source code.
by odiseo
JavaScript
function getScript ( url, callback ) {
var script,
head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
script = document.createElement( "script" );
script.async = "async";
script.src = url;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function( ) {
if ( !script.readyState ) {
// Handle memory leak in IE
script.onload = script.onreadystatechange = null;
// Remove the script
if ( head && script.parentNode ) {
head.removeChild( script );
}
callback();
}
};
// Use insertBefore instead of appendChild to circumvent an IE6 bug.
head.insertBefore( script, head.firstChild );
console.log(script);
return 'rad!';
}
getScript('http://www.cornify.com/js/cornify.js', function(){
var times = 100;
while(--times)
cornify_add();
});