I have 4-5 scripts running on one page at any given time. I have them in the order I want them to load but it seems the scripts I have starting first are lagging while the rest of the other scripts load so in turn the script loaded first seems to finish loading last.
ex
jquery
flash detect
js menu
dom analytic
but even in that order jquery finishes loading last. How can i set a delay to the rest of the scripts without modding them? some of them are within the page but others are external absolute paths to other scripts.
I have a few projects that write new arrays. When the page closes, I wish to write a new .js file and save it (local application) So now, I have some options to load different .js scripts from form buttons. I'm very sure you could use this script to call each one and after load, load the next. If it doesn't happen to your satisfaction, could use a setTimeout function....
PHP Code:
function loadJS(url){ url=bckslash(url); var ul=url.substring(url.lastIndexOf('.')+1,url.length); ul=ul.toUpperCase(); document.getElementById('sounds').style.visibility='visible';
if( ul=='JS'){
var e = document.createElement("script");
e.src = url;
e.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(e);
document.getElementById('jsLoaded').innerHTML=url.substring(url.lastIndexOf('\\')+1,url.length);document.getElementById('jsLoaded').title=url;
grabFolder(path)
}
else{for(i=0;i<showImgExt.length;i++){if(ul==showImgExt[i]){grabFolder( url.substring(0,url.lastIndexOf('\\')),url.substring(0,url.lastIndexOf('\\')) );}}
}
}
sorry, there's probly lines there you don't need. The bckslash function replaces forward slashes in the path. If your scripts are in the same directory, no need for that.
In my application, I was using a file input form button to browse. The slashes are forward or backward, its a mess. I only ripped the code out of an existing file. You can see it's only handling .js files,, here this might be better
PHP Code:
function loadJS(url){
var e = document.createElement("script");
e.src = url;
e.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(e);
}
Now, just use a group of buttons to load your scripts. Still, it looks like this only works on .js don't worry about slash, just use the full path in the argument of the function
Bookmarks