Reference

Web Workers glossary

Shared vocabulary for this workspace. Lessons stick to these meanings.

Main thread (UI thread)
The browser tab’s primary thread: runs most page JavaScript, layout, paint, and input handling. Long tasks here freeze the UI. Other platforms often call this the UI thread.
Web Worker
A background JavaScript execution context running on a separate thread from the main thread. Defined in the HTML Living Standard. Cannot touch the DOM directly; talks via messages.
Dedicated worker
A worker used by a single script (one owner). Created with new Worker(url). Global scope: DedicatedWorkerGlobalScope. Default design choice for “move this compute off the UI.”
Shared worker
A worker that multiple browsing contexts (tabs, windows, iframes) of the same origin can connect to. Uses port-based messaging (SharedWorker / MessagePort). Later in this track — not lesson 1 depth.
Service worker
A different kind of worker: a network proxy between the page, the browser, and the network (offline, caching, push). Same “worker” family name; different job. Comparison-only in this mission.
Off-main-thread (OMT)
Architecture habit of running non-UI work away from the main thread so layout, paint, and input stay free. Workers are the web’s main OMT primitive for app logic.
postMessage
The API both sides use to send data across the main thread ↔ worker boundary. Data is copied (structured clone) by default, not shared like OS threads sharing variables.
Structured clone
The algorithm that copies values sent via postMessage. Most plain data works; some types (e.g. functions, DOM nodes) do not cross. Cost matters for large payloads — later lessons.
Isolation (no shared memory by default)
Workers do not share JavaScript variables with the page. Each has its own global scope. Coordination is messages (or advanced transferables / SharedArrayBuffer — later).
Long task
Main-thread work that runs long enough to block input and rendering (often discussed against ~50ms budgets and RAIL-style thresholds). Primary reason teams reach for workers.
Yielding / chunking
Breaking main-thread work into smaller tasks so the browser can paint and handle input between chunks. Keeps work on the main thread; does not parallelize. Alternative (or complement) to a worker.
Worklet
Spec infrastructure for short specialized scripts (audio, paint, etc.), not general-purpose app workers. Out of scope except as a label.
terminate()
Main-thread method on Worker that immediately kills the worker thread. Does not wait for in-flight work to finish. Default cleanup on SPA unmount.
close()
Called inside a dedicated worker to shut down its own scope: discard queued tasks and stop further work. Different API surface from main-thread terminate().
messageerror
Event on Worker when an incoming message cannot be deserialized (structured-clone failure on the receiving side).
Module worker
Worker constructed with { type: "module" }. Gets ES module semantics (import, strict mode). Classic workers use importScripts() instead.
Transferable object
A resource that can be moved between realms via the postMessage transfer list (e.g. ArrayBuffer). After transfer, the sender no longer owns it (buffer is detached).
Detached buffer
An ArrayBuffer (or view over it) whose memory was transferred away. Typical symptom: byteLength === 0; further use throws.
DataCloneError
Exception when structured clone cannot copy a value — classic cases: functions and DOM nodes in a postMessage payload.
Patch / patchset
Design pattern: send only state diffs across the worker boundary instead of cloning an entire large object every update.
BroadcastChannel
Same-origin pub/sub between browsing contexts. No shared worker process — only messages. Often enough for “tell other tabs X.”
MessagePort
Explicit two-way message endpoint. Shared workers expose one per connecting context via SharedWorker.port / connect event ports.