Skip to content

JS Module Scripts in more contexts (2027 edition) #1386

Open

Description

@PolariTOON

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

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:

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.

Activity

  1. github-actions commented on Sep 9, 2026

    @github-actions

    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

  2. gsnedders commented on Sep 9, 2026

    @gsnedders
    Member

    web-features: js-modules

    Given you reference a number of things above, we maybe want to also include:

    • js-modules-shared-workers
    • js-modules-service-workers
    • js-modules-workers
    • modulepreload
    • import-maps
  3. jgraham commented on Sep 11, 2026

    @jgraham
    Contributor

    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:

    • Modules in XHTML documents
    • Modules in SVG documents
    • Modules in Web Extensions

    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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    focus-area-proposal

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions