What is Web Worker?
A browser thread for running JavaScript off the main thread, keeping the UI responsive during heavy computation.
Definition
Web workers execute scripts on background threads, communicating with the page via postMessage and structured cloning—or zero-copy transfer of ArrayBuffers and SharedArrayBuffer for high-throughput cases. Because the main thread owns rendering and input handling, moving work like image processing, parsing large JSON, cryptography, or WebAssembly execution into a worker prevents jank and long-task violations in INP. Workers have no DOM access; OffscreenCanvas is the notable exception, enabling off-thread rendering. Libraries like Comlink wrap the messaging protocol in an async RPC interface. Dedicated workers serve one page; shared workers can serve several same-origin tabs.

