Repository navigation
Description
Description
ECMA262 specifies two kinds of goal symbols for JavaScript: (classic) scripts and modules. The JS ecosystem keeps moving towards using modules, both on the web platform and server-side runtimes, both as an authoring and distribution format, however not every browser supports them in every context. This issue is about improving interoperability for JS modules in contexts where browser support is already existent but partial, in particular, XHTML documents, SVG documents, but also Web Extensions if they are in the scope of the Interop project, which I am unsure of.
This was previously submitted for Interop 2025 (see #869). While not accepted at the time, there still has been some progress in this area since then:
- every major browser now supports JS modules in Service Workers in web content
- a new API for running Web Extensions has been added to WPT, through which this area could likely be tested nowadays
Specification
See https://tc39.es/ecma262/#sec-modules for the main spec defining modules though this issue is more about their integration in multiple other consuming specs (see links below)
web-feature
web-features: js-modules
Test Links
<script type="module">in HTML documents with XML syntax (aka XHTML documents) : https://wpt.fyi/results/html/semantics/scripting-1/the-script-element/module/module-in-xhtml.xhtml<script type="module">in SVG documents : https://wpt.fyi/results/svg/interact/scripted/module-01.svg- HTML namespaced
<script type="module">in SVG documents : TBD "type": "module"for background scripts defined via the"background.service_worker"key in Web Extension Manifests: TBD
Additional Signals
Site Breakage and Workaround
Code expected to be consumed as JS modules (using syntax-enabled features such as static imports, top-level await or whose execution should be deferred) can not be run everywhere.
For example, one can not write a module that runs both in a HTML document, a XHTML document, and a SVG document. Also one can not write a Web Extension Service Worker background script that runs in every browser.
Currently, instead of being able to distribute isomorphic code using only JS modules, multiple distribution targets are required.
Current State of the Feature
Use share for JS modules on the web keeps increasing: https://chromestatus.com/metrics/webfeature/timeline/popularity/47
Integration specs, existing tests, documentation, browser bugs and implementation status
This issue is about improving interoperability for JS modules in contexts where browser support is already partial, such as:
<script type="module">in HTML documents with XML syntax (aka XHTML documents)- WHATWG spec: https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
- WPT: https://wpt.fyi/results/html/semantics/scripting-1/the-script-element/module/module-in-xhtml.xhtml
- MDN documentation: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script#module
- Blink bug: https://issues.chromium.org/issues/40518469 (33 votes)
- Gecko bug: TBD (already implemented)
- Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=227469
<script type="module">in SVG documents- W3C spec: https://w3c.github.io/svgwg/svg2-draft/interact.html#ScriptElement
- WPT: https://wpt.fyi/results/svg/interact/scripted/module-01.svg
- MDN documentation: https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/script#type (incomplete)
- Blink bug: https://issues.chromium.org/issues/40067618 (5 votes)
- Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1839954 (already implemented)
- Webkit bug: TBD
- HTML namespaced
<script type="module">in SVG documents- W3C spec: https://w3c.github.io/svgwg/svg2-draft/struct.html#HTMLMetadataElements
- WPT: TBD
- MDN documentation: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script#module
- Blink bug: TBD
- Gecko bug: TBD (already implemented)
- Webkit bug: TBD
"type": "module"for background scripts defined via the"background.service_worker"key in Web Extension Manifests- WECG spec: https://w3c.github.io/webextensions/specification/index.html#key-background (incomplete)
- WPT: TBD
- Chrome documentation: https://developer.chrome.com/docs/extensions/reference/manifest/background
- MDN documentation: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background
- Blink bug: TBD (already implemented)
- Gecko bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1775574 (7 votes)
- Webkit bug: TBD (already implemented)
Out of scope features
See the previous issue for examples of other contexts / integration points where JS modules could be added, but are not yet supported in any browser AFAIK.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
github-actions commentedon Sep 9, 2026
This comment was automatically generated based on the information you provided. Please don't edit it.
Below is additional information about the web feature (from the web-features project) which is referenced in your proposal.
If this doesn't accurately correspond to your proposal, please update your initial comment to include
web-features: <feature-id>.To find feature IDs, use the web-features explorer.
Feature JavaScript modules
importto load other modules andexportto declare what is available to import from other modules. In HTML, modules are loaded with<script type="module">.<script type>HTML attributegsnedders commentedon Sep 9, 2026
Given you reference a number of things above, we maybe want to also include:
jgraham commentedon Sep 11, 2026
I think it might make sense to split this into multiple proposals that can be assessed separately. It seems like there are at least 3 things in the original proposal that are somewhat distinct:
The web extensions case seems like it would be difficult to include because there isn't a spec, and I suspect there also aren't tests. Do the other parts of the proposal have tests?