This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 18979 - provide way to guarantee order of execution for async scripts
Summary: provide way to guarantee order of execution for async scripts
Status: RESOLVED WONTFIX
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 enhancement
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-23 21:27 UTC by David Alimian
Modified: 2016-04-20 19:30 UTC (History)
6 users (show)

See Also:


Attachments

Description David Alimian 2012-09-23 21:27:02 UTC
currently html 5 spec provides no clean way for a web developer to ensure order of execution of async scripts.

One simple solution to achieve this is to introduce a new attribute to script element - "group"

the idea is that if one has
<script async="async" group="group1" ...></script>

then this script will not be executed until any previous scripts of same group have finished executed. This should be simple for browsers to implement,- when the browser is parsing a script with group="groups1" it just checks if it currently has a download or execution of a script belonging to that group, if not, execute.

This would make the web lot faster.

What you think?

to achieve a similar result currently developers are loading the scripts dynamically (thus async) and listening to the onload event for the script, then in the onload they download a dependent script, - this is a huge performance concern cause in this case the downloads happen sequentially and we want the downloads to happen in parallel.
Comment 1 Robin Berjon 2013-01-21 15:58:23 UTC
Mass move to "HTML WG"
Comment 2 Robin Berjon 2013-01-21 16:01:10 UTC
Mass move to "HTML WG"
Comment 3 Arron Eicholz 2016-04-20 18:47:59 UTC
HTML5.1 Bugzilla Bug Triage: This is solved by using modules. You can create and order using chained imports and then async.
Comment 4 David Alimian 2016-04-20 19:04:39 UTC
Thanks Arron, could u provide a link to documentation tho
Comment 5 Travis Leithead [MSFT] 2016-04-20 19:30:45 UTC
Here's some early details: https://24ways.org/2014/javascript-modules-the-es6-way/

The EcmaScript spec: https://tc39.github.io/ecma262/2016/ (specifically: https://tc39.github.io/ecma262/2016/#sec-ecmascript-language-scripts-and-modules)

<script type="module"> is here for now: https://html.spec.whatwg.org/#the-script-element