From 51562999c7ff981c29264aecf7dbdd5c0375590a Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Thu, 1 Nov 2012 10:47:37 -0500 Subject: [PATCH] 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. --- include/util.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/include/util.js b/include/util.js index f3b558e5..6f6c52a6 100644 --- a/include/util.js +++ b/include/util.js @@ -242,10 +242,11 @@ Util.load_scripts = function(files) { this.onload = this.onreadystatechange = null; //console.log("completed script: " + this.src); ps.splice(ps.indexOf(this), 1); - } - // Call window.onscriptsload after last script loads - if (ps.length === 0 && window.onscriptsload) { - window.onscriptsload(); + + // Call window.onscriptsload after last script loads + if (ps.length === 0 && window.onscriptsload) { + window.onscriptsload(); + } } } };