Forma saysWeb Workers run JavaScript on a background thread so heavy work never freezes the page.
JavaScript is single-threaded — a long loop freezes the whole UI. A Web Worker runs a separate script on its own thread. You talk to it with postMessage and listen with onmessage; it can't touch the DOM, only crunch data and message results back.
Use workers for parsing big files, image processing, or any computation that would otherwise janky-up scrolling and clicks. Normally a worker is its own file; you can also build one from a Blob URL for single-file demos.
Power-ups you unlock
Workers run on a background thread (no UI freeze)
Communicate via postMessage / onmessage
No DOM access inside a worker — data only
Great for parsing, math, image processing
Captain Invalid Input attacks — common mistakes
Trying to touch the DOM from inside a worker
Passing huge objects by copy each message (use transferables)
Spawning workers for trivial work (overhead exceeds benefit)
Boss battleSpin up an inline (Blob) worker that sums to 100 million and posts the result back without freezing the button.