-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
importScripts should be able to fetch in parallel and execute synchronously #3775
Comments
I'm not sure why it's written this way, but here are some guesses:
I'd be in favor of loosening the spec here, if there are multiple vendors on board (or maybe some already implement this way). Based on your username, maybe you have some insight into the Edge team's implementation? However, it might not be worth changing this, given that the future lies in module workers---which have a much more robust script-importing mechanism that already works in the way you desire. We'll see what folks think. /cc @wanderview from Gecko and @nhiroki from Blink to get their perspective. |
Edge team is onboard (I did speak with them) and blink team seems to be onboard as well: https://bugs.chromium.org/p/chromium/issues/detail?id=856488#c3 Thanks |
This may be useful to some while we wait for proper module worker support to roll out over the next whatever chunk of time. This feature can be implemented much more quickly. |
Firefox already implements parallel fetching for It requires that they execute in order, though. That is enforced in this code: AFAICT this behavior has been there since the first worker implementation in gecko. |
Note, when parallel fetching was implemented I don't think it was observable. It probably is observable now, though, via FetchEvent if the worker is controlled. |
What should happen in the following scenario?
Seems like the result should be to run the contents of |
I think given the fact that its considered syntactic sugar, that makes sense as the caller script should fail out. |
Fixes #3775. As noted there in more detail, this doesn't change much of the semantics. Execution order is still synchronous, and errors are still thrown in the same deterministic fashion for both network failures and script-running failures. Indeed, Gecko already implements these semantics. It's likely that at the time this specification was originally written, whether these fetches were in parallel or sequential was not observable, at least by client-side code. However, these days, with the web performance APIs and with service workers, it's very observable, and we should be sure that parallel fetching is allowed. For reference, here is a 2015-08-27 snapshot of this method, before any of the script-loading refactorings and changes due to module scripts: https://html.spec.whatwg.org/commit-snapshots/c9e804f04d03a0658bfa689cb0f368a4d2e37936/#dom-workerglobalscope-importscripts You can see that it was sequential even then.
Hi,
I'm looking to change the spec so that importScripts("a.js", "b.js") will download a.js and b.js in parallel and then execute synchronously.
Today, the spec forces vendors to download a.js, execute a.js, and then start downloading b.js before executing b.js. This forced serialization is unoptimized. Instead, the spec should only stipulate the execution order and place no requirements on download order. OR, force vendors to download in parallel.
Is there some reason it has been written such that script downloads wait for previous script execution?
Thanks
The text was updated successfully, but these errors were encountered: