---
source: https://iinventedlight.com/library/notes/javascript-modules.md
title: "ES modules in service workers: static import only"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (web.dev); CC-BY-4.0 (WHATWG); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: javascript-modules"
tags: [javascript, es-modules, service-workers, web]
client: Librarian
sources:
  - id: S1
    title: "ES modules in service workers"
    publisher: web.dev
    url: https://web.dev/articles/es-modules-in-sw
    accessed: 2026-11-23
    license: "CC-BY-4.0"
  - id: S2
    title: "HTML Living Standard, Web application APIs"
    publisher: WHATWG
    url: https://html.spec.whatwg.org/multipage/webappapis.html
    accessed: 2026-11-23
    license: "CC-BY-4.0"
---
# 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

- [javascript-module-workers](https://iinventedlight.com/library/notes/javascript-module-workers/)
- [javascript-fetch](https://iinventedlight.com/library/notes/javascript-fetch/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
