You are here: DEVPPL Forum Programming JavaScript Forum Script-archive
NOTIFICATIONS
54.069
MEMBERS
15.678
TOPICS
62.243
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

Loading JS file with a JS function

0

Loading

Loading JS file with a JS function

Postby HotNoob » Fri Sep 24, 2010 5: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
 
Reputation: 0
Posts: 169
Joined: Sun May 02, 2010 2:38 am
Highscores: 0
Arcade winning challenges: 0

Loading JS file with a JS function - Sponsored results

Sponsored results

Login to get rid of ads

 

^ Back to Top