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
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.
License: CC-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.
Cite this
iinventedlight. 2026. "Module workers: ES modules on a background thread." iinventedlight Library, iil:note:af5fh92v, version of 2026-11-23. https://iinventedlight.com/library/notes/javascript-module-workers/. License: CC-BY-4.0.
@misc{iil_note_af5fh92v,
author = {{iinventedlight}},
title = {{Module workers: ES modules on a background thread}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/javascript-module-workers/},
note = {Permanent ID iil:note:af5fh92v. 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-module-workers.schema.json (schema; CC-BY-4.0)
- javascript-module-workers.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-module-workers.md.