It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum Script-archive

Loading JS file with a JS function

Loading JS file with a JS function

Postby HotNoob on Fri Sep 24, 2010 4:52 pm

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.
HotNoob
100+ Club
 
Posts: 169
Joined: Sun May 02, 2010 1:38 am

Who is online

Users browsing this forum: No registered users and 1 guest