ES modules in service workers: static import only
Answer: Service workers can load ES modules, but only with static import syntax today. A Source Text Module Record is used for JavaScript module scripts.
Static import in a service worker
web.dev presents ES modules as a modern alternative to importScripts().
Modules can be pulled in statically with import ... from '...', or dynamically with the import() method.
Inside of a service worker, only the static syntax is currently supported.
That limit is analogous to a similar restriction on importScripts() usage. Dynamic importScripts() calls do not work there either.
How HTML describes module scripts
A Source Text Module Record is used for JavaScript module scripts.
HTML also describes CSS module scripts and JSON module scripts, plus WebAssembly module scripts.
See also
Claims
- id: C1 claim: ES modules are described as a modern alternative to importScripts(). source: S1 evidence: "A modern alternative to importScripts()"
- id: C2 claim: Inside a service worker, only static import syntax is currently supported. source: S1 evidence: "only the static syntax is currently supported"
- id: C3 claim: HTML uses a Source Text Module Record for JavaScript module scripts. source: S2 evidence: "Source Text Module Record , for JavaScript module scripts"
- id: C4 claim: HTML also describes CSS, JSON, and WebAssembly module scripts. source: S2 evidence: "CSS module scripts , JSON module scripts"
Sources
- [S1] ES modules in service workers. web.dev. https://web.dev/articles/es-modules-in-sw . License: CC-BY-4.0. Accessed 2026-11-23.
- [S2] HTML Living Standard, Web application APIs. WHATWG. https://html.spec.whatwg.org/multipage/webappapis.html . License: CC-BY-4.0. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, ES modules in service workers; WHATWG, HTML Living Standard, Web application APIs. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://raw.githubusercontent.com/whatwg/html/main/LICENSE). Copyright WHATWG contributors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: web.dev, ES modules in service workers; WHATWG, HTML Living Standard, Web application APIs. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. CC-BY-4.0 (https://raw.githubusercontent.com/whatwg/html/main/LICENSE). Copyright WHATWG contributors.
Cite this
iinventedlight. 2026. "ES modules in service workers: static import only." iinventedlight Library, iil:note:4za8z32s, version of 2026-11-23. https://iinventedlight.com/library/notes/javascript-modules/. License: CC-BY-4.0.
@misc{iil_note_4za8z32s,
author = {{iinventedlight}},
title = {{ES modules in service workers: static import only}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/javascript-modules/},
note = {Permanent ID iil:note:4za8z32s. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- javascript-modules.schema.json (schema; CC-BY-4.0)
- javascript-modules.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/javascript-modules.md.