---
source: https://iinventedlight.com/library/notes/javascript-module-workers.md
title: "Module workers: ES modules on a background thread"
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, Threading the web with module 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-module-workers"
tags: [javascript, workers, es-modules, web]
client: Librarian
sources:
  - id: S1
    title: "Threading the web with module workers"
    publisher: web.dev
    url: https://web.dev/articles/module-workers
    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"
---
# Module workers: ES modules on a background thread
**Answer:** A module worker is a web worker started from an ES module. Pass { type: 'module' } to the Worker constructor. HTML includes an algorithm to fetch a module worker script graph given a URL.

## Why workers exist

Ordinary JavaScript can only perform one operation at a time, because the language is single-threaded.

The Web Workers API is the main primitive the web platform provides for parallelism and threading.

Workers are a lightweight abstraction on top of operating system threads. They expose a message passing API for inter-thread communication.

## Loading a module in a worker

JavaScript modules in web workers make it easier to move heavy lifting into background threads.

Construct the worker as new Worker('worker.js', { type: 'module' }).

Modules that were preloaded can be used by module workers and by the main thread alike.

## The HTML fetch model

HTML defines an algorithm named fetch a module worker script graph, and it is given a URL.

## See also

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

## Claims

- id: C1
  claim: JavaScript is single-threaded and can only perform one operation at a time.
  source: S1
  evidence: "JavaScript is single-threaded"

- id: C2
  claim: Create a module worker with new Worker(url, { type: 'module' }).
  source: S1
  evidence: "type: 'module'"

- id: C3
  claim: Preloaded modules can be used by the main thread and module workers.
  source: S1
  evidence: "used by both the main thread and module workers"

- id: C4
  claim: HTML defines how to fetch a module worker script graph given a URL.
  source: S2
  evidence: "fetch a module worker script graph given a URL"

## Sources

- [S1] Threading the web with module workers. web.dev. https://web.dev/articles/module-workers . 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, Threading the web with module 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).
