What Is a Shared Worker?
A shared worker is a background script that several documents from the same origin can connect to simultaneously, all talking to a single worker instance. Each connection communicates through a port, and the worker can coordinate state across tabs. This makes it useful for shared resources like a single websocket or a common cache.
Why it matters
A dedicated web worker exists per page, so multiple tabs duplicate work and connections. A shared worker centralizes that, letting tabs share one connection or computation and stay in sync.
Related guides
What Is a Web Worker?A web worker runs JavaScript on a background thread separate from the main UI thread, communicating via messa…
What Is a Service Worker Cache?A service worker cache is a programmable store that a service worker uses to intercept requests and serve res…
What Is a Dynamic Import?A dynamic import loads a JavaScript module on demand at runtime, returning a promise, which enables code spli…