Skip to content

Browser Support

Dedicated Worker / SharedWorker: Nearly all browsers

Service Worker: Chrome 40+ · Firefox 44+ · Safari 11.1+ · Edge 79+

Worklet: Chrome 49+ / Safari incomplete support

Overview

Many people confuse Service Worker with Dedicated/Shared Workers, thinking they're all "background threads". Actually, they solve completely different problems:

  • Dedicated / Shared Worker: Help main thread share compute load, communicate via postMessage
  • Service Worker: Acts as a proxy between browser and network, intercepts/manages requests via event-driven fetch responses

Service Worker is not a Worker thread; it's a separate lifecycle running under the registered domain, more like a script running in the background that can intercept network requests, push notifications, manage caches.

A Table Explains the Differences

FeatureDedicated WorkerShared WorkerService Worker
Creationnew Worker(url)new SharedWorker(url, name)navigator.serviceWorker.register(url)
Thread modelIndependent threadIndependent thread (shareable across tabs)Independent thread (event-driven)
DOM accessNoNoNo
Network requestsfetchfetchfetch + Intercept fetch
Cache managementNoNoCache API / Cache Storage
Push notificationsNoNoPush API / Notification API
Lifecycleterminate() / close()close()Install → Activate → Deprecated
Offline capabilityNoNoCan implement offline apps
ScopeOwnSame originHas path scope
CommunicationpostMessagepostMessage (via port)Events (fetch, push, message)
Use caseCompute-intensive tasksCross-tab shared stateNetwork proxy, PWA offline, push

When to Use Which?

Do you need to intercept network requests?
  ├── No → Do you need cross-tab shared state?
  │         ├── No → Dedicated Worker
  │         └── Yes → Shared Worker (or BroadcastChannel)
  └── Yes → Service Worker (PWA / offline apps / push)

Notes

  • HTTPS required: Service Worker must run under HTTPS (except localhost)
  • Scope restrictions: Service Worker's scope determines which path requests it can intercept; subpaths are covered, parent paths are not
  • Multiple versions can coexist: Old version is garbage collected after all pages stop using it
  • self in Service Worker is ServiceWorkerGlobalScope: Has caches, fetch, clients APIs not available in Dedicated Worker
  • Service Worker events disappear after exit: It only lives when events trigger; browser suspends it when idle — this is by design, not a bug

Released under the MIT License.