util.js: script load sequential execution changes.

Related to issue: https://github.com/kanaka/noVNC/issues/205

Split out the function to load a single script to Util.load_script.

In order to get sequential load, when on IE set the script defer flag.
It is currently working on webkit and firefox but just in case also
set the script.async flag to make sure that scripts execute in the
order they are added. Scripts should still load in parallel.
This commit is contained in:
Joel Martin 2012-11-01 10:47:37 -05:00
parent e7e6660272
commit 51562999c7
1 changed files with 5 additions and 4 deletions

View File

@ -242,12 +242,13 @@ Util.load_scripts = function(files) {
this.onload = this.onreadystatechange = null; this.onload = this.onreadystatechange = null;
//console.log("completed script: " + this.src); //console.log("completed script: " + this.src);
ps.splice(ps.indexOf(this), 1); ps.splice(ps.indexOf(this), 1);
}
// Call window.onscriptsload after last script loads // Call window.onscriptsload after last script loads
if (ps.length === 0 && window.onscriptsload) { if (ps.length === 0 && window.onscriptsload) {
window.onscriptsload(); window.onscriptsload();
} }
} }
}
}; };
// In-order script execution tricks // In-order script execution tricks
if (Util.Engine.trident) { if (Util.Engine.trident) {