- Code: Select all
function loadScript(src)
{
var s=document.createElement("script");
s.setAttribute("type","text/javascript");
s.setAttribute("id", "");
s.setAttribute("src", src);
document.getElementsByTagName("head")[0].appendChild(s);
}
Simply put the url of the .Js file that you want to load into the function.
For example
- Code: Select all
loadScript("someFile.js");
This function can be useful if you are using php combined with js, and want to conserve on the loading time as well as the overall bandwidth.


