You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Considering the full combinatorics of the space, there are four different independent variables for how to execute top-level code:
HTML vs JS: is the code loaded from an HTML tag or from a JS constructor?
script vs module: is the code executed as an ES(6) Script or Module?
worker vs sync: is the code loaded in a worker or synchronously?
URL vs source: is the code provided as a source string or a URL to an external file?
This leads to 2^4=16 combinations that have to be considered for the design. It doesn't mean authors actually have to deal with all this combinations, since (a) they don't all have to be supported, and (b) some can eventually become old-fashioned legacy.
There are also multiple kinds of workers (Worker, SharedWorker, ServiceWorker, possibly more in the future?).
The existence of Worker, SharedWorker, ServiceWorker, and possibly more in the future suggests that the only extension point possible is a new extensibility dimension in the argument (which currently coerces everything to a string). Hence: a new Work constructor that gets overloaded with DOMString. Not ideal for ergonomics but a step forward, and convenience wrappers (e.g. a spawn function) are still possible.
A worker attribute is possible but probably not advisable, especially given these additional dimensions like shared, service, etc.
A <script module> should ignore its type attribute entirely, always assuming 'application/javascript'. The <module> tag should be an alias for this, and in time should become the preferable development model. Medium-term apps that deploy to down-rev browsers can use <script type="x-es6" module> and do their own runtime transpiling.
The Work constructor should default to accepting a Module since that's generally more flexible than Script. However, we can't just make Worker et al accept Module in the future, since that's implicitly strict and likely to break the web. :'-(