← All notes

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

Sources

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

Permanent ID: iil:note:af5fh92v

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.},
}

Markdown

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.

All artifact files (JSON index)

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.