function loadScript( url, callback ) {
var script = document.createElement( "script" )
script.type = "text/javascript";
script.src = url;
script.onload = function() {
callback()
};
document.head.appendChild(script);
}
// call the function...
loadScript("js/myscript.js", function() {
alert('script ready!');
});