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

[whatwg] Script loading and execution order for importScripts

From: Jonas Sicking <jonas@sicking.cc>
Date: Sat, 7 Mar 2009 01:31:38 -0800
Message-ID: <63df84f0903070131s3af65095td5286b571d3833c7@mail.gmail.com>
On Sat, Mar 7, 2009 at 1:20 AM, ben turner <bent.mozilla at gmail.com> wrote:
> On Fri, Mar 6, 2009 at 8:40 PM, Oliver Hunt <oliver at apple.com> wrote:
>> 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.
>
> You are half-correct :)
>
> Currently we load all scripts in parallel and then _compile_ each
> script as soon as it has finished loading (which can be in any order).
> We do not _execute_ them, however, until all loading and compilation
> have completed successfully, and then we execute them in the order of
> the arguments passed to importScripts.
>
> You're right that this is different from the behavior described in the
> spec... I was supposed to mail this list a while ago and completely
> forgot, many apologies. We felt that our approach was a good
> compromise between executing only some of the scripts and executing
> each script as soon as possible. We are certainly open to any better
> alternatives. Do other JS engines have support for separating the
> compilation and the execution of scripts?

What I like about what the spec does is that we can execute the first
scripts while the following scripts are still loading, which is better
for performance. It doesn't really seem adventitious to optimize for
the case when a script fails to load or parse as that is hopefully
very rare. Most likely the worker is going to have to abort everything
anyway in case a script can't be executed, so if that happens after
one or two scripts have executed doesn't really seem to be a downside.

/ Jonas
Received on Saturday, 7 March 2009 01:31:38 GMT

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