Web Worker
A background thread for running JavaScript off the main thread, with no access to the DOM.
Web Worker runs a JavaScript file on a separate thread from the page's main thread, so a genuinely expensive computation — parsing a large file, running a physics simulation, image processing — doesn't block scrolling, clicking, or rendering while it runs. JavaScript's usual single-threaded Event Loop model is what makes this necessary in the first place: one long synchronous function on the main thread freezes the entire page for its duration, no matter how responsive the rest of the code is.
The tradeoff that defines what a worker is for is that it has no access to the Document Object Model at all — it can't touch an element, read layout, or call a DOM API. It communicates with the main thread purely through message passing: postMessage sends a value across (structured-cloned, not shared by reference, so mutating an object on one side doesn't affect the other's copy), and a message event delivers it. This makes a worker suitable for pure computation and unsuitable for anything that needs to read or write the page directly — which is most UI work, and exactly why workers are a niche tool rather than a default.
A Service Worker is a specialized sibling, not a general-purpose worker: same off-main-thread, no-DOM-access model, but scoped to intercepting network requests for an origin and capable of outliving the page that registered it, where a plain Web Worker dies when its page does and exists to compute, not to proxy the network.
SharedWorker is a third variant, reachable from multiple tabs of the same origin at once, useful for coordinating state across tabs without each one running its own duplicate worker — though its main-thread access restriction is identical to a plain worker's.
See also3
Service Worker
A background script the browser runs between a page and the network, able to intercept requests even when no page is open.
Web Platform12 connections
Debounce and Throttle
Two opposite strategies for limiting how often a handler runs against a rapid stream of events.
Web Platform11 connections
Performance Budget
A committed numeric ceiling on a page's cost, enforced automatically.
Web Platform26 connections
Related3
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from9
- Background Tab ThrottlingWeb Platform
Browsers deliberately slow, freeze, or discard pages that are not visible, so code that assumes it keeps running in the background will be wrong.
- Debounce and ThrottleWeb Platform
Two opposite strategies for limiting how often a handler runs against a rapid stream of events.
- Event LoopComputation & Algorithms
A single-threaded runtime's mechanism for pulling the next callback off a queue once the call stack is empty.
- IframeWeb Platform
A whole web page embedded inside another, the web's main isolation boundary for ads, payments, and widgets, and the messaging and sandboxing rules that govern it.
- Long TaskWeb Platform
Any stretch of main-thread work over 50 milliseconds, during which the page can't respond to input, and the techniques for breaking such work up.
- PromiseWeb Platform
JavaScript's object for a value that will arrive later, how it replaced nested callbacks, and the microtask queue that decides when its handlers run.
- requestAnimationFrameWeb Platform
The browser callback that runs once per display frame just before paint, which is the right clock for visual work and stops entirely when nothing is being displayed.
- Service WorkerWeb Platform
A background script the browser runs between a page and the network, able to intercept requests even when no page is open.
- WebSocketWeb Platform
A persistent, full-duplex connection between browser and server, replacing repeated request-response with an open channel.