Load JavaScript dynamically
This is the snippet you can use.
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://example.com/some.js";
document.body.appendChild(script);
}
The code is self explained. You have to add only onload event in the body tag or this at the bottom of the page
window.onload = loadScript();