| You are here: DEVPPL ‹ Forum ‹ Programming ‹ JavaScript Forum ‹ Script-archive |
NOTIFICATIONS
|
|
|||||||||||||||
Login |
Loading JS file with a JS function
1 post
• Page 1 of 1
0
Loading JS file with a JS function
- 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
|
|