Web worker recording

Web worker recording is the pattern of moving the expensive parts of session recording, such as serialization work, compression, and network transmission, off the page's main thread into a web worker. Capture itself must observe the DOM from the main thread, but most of what happens to an event afterward does not need to run there.

How it works

The browser's DOM APIs, including MutationObserver, are main-thread only, so the observation and initial serialization stay put. The rrweb observer documentation describes the recording-side constraint. Everything downstream can be delegated: the main thread posts raw event data to a worker, and the worker handles compression (packing is the classic candidate), batching, and upload via fetch or WebSocket from worker context. The payoff is jank protection: a large mutation burst compressing on the main thread can cause visible frame drops, and moving that work keeps recording overhead within the budget users never notice. The cost is structured message passing and slightly more complex failure handling across the thread boundary.

Where you encounter it

Performance-sensitive deployments and overhead audits; measure recording cost on the heaviest pages and devices you support.