W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2009

[whatwg] Script loading and execution order for importScripts

From: Oliver Hunt <oliver@apple.com>
Date: Fri, 6 Mar 2009 20:40:20 -0800
Message-ID: <D9B68745-C5D9-4C02-8643-C38B3AA10632@apple.com>
So I've been looking at importScripts (http://www.whatwg.org/specs/web-workers/current-work/#importing-scripts-and-libraries 
  ) and found that the behaviour of Mozilla differs from the behaviour  
defined in the spec.  The spec behaviour is

(pseudo code, skipping url validation, etc)
function importScripts(sources) {
     for (source in sources) {
         script = loadScript(source);
         if (load failed)
              throw NETWORK_ERR
         execute(script);
     }
}

This means that any scripts specified before the failing resource load  
will have executed, whereas Mozilla's behaviour appears to be:
function importScripts(sources) {
     scripts = [];
     for (source in sources) {
         script = loadScript(source);
         if (load failed)
              throw NETWORK_ERR
         scripts.push(script);
     }
     for (script in scripts)
         execute(script)
}

Which means that none of the scripts will execute if any script fails  
to load.

In all honesty i'm not sure which is the better approach as the spec  
approach requires developers to manually handle the potential for  
partial library execution, but the Mozilla approach removes the  
ability to load and execute scripts in parallel, which may cause  
latency problems.

Does anyone else have any thoughts as to whether the spec should be  
changed to match Mozilla behaviour, or whether the Mozilla behaviour  
should be considered "incorrect"?

--Oliver
Received on Friday, 6 March 2009 20:40:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:47:49 GMT