Testing

SharedWorker: Browser Support, API, Limitations

SharedWorker works in Chrome 4+, Edge 79+, Firefox 29+, Opera 10.6+, and Safari 16+. Learn browser support, key features, use cases, and known issues.

Author

Prince Dewani

May 1, 2026

SharedWorker is a WHATWG HTML JavaScript API that runs one background script which multiple same-origin tabs, iframes, and workers connect to through a MessagePort. It works in Chrome 4+, Edge 79+, Firefox 29+, Opera 10.6+, and Safari 16+, while Chrome for Android, Samsung Internet, the Android Browser, and Internet Explorer never added support.

This guide covers what SharedWorker is, the browsers that support it, the key features, common use cases, differences from Web Worker and Service Worker, and known issues.

What is SharedWorker?

SharedWorker is a JavaScript interface defined in the WHATWG HTML Living Standard. It loads a single worker script in the background, and any same-origin page, iframe, or worker can connect to it through the SharedWorker constructor. Communication happens over a MessagePort exposed on the .port property.

Which browsers does SharedWorker support?

SharedWorker works in every desktop Chromium, Gecko, and WebKit browser, while every Chromium-based mobile browser, the legacy Android Browser, and Internet Explorer do not support it.

Loading browser compatibility data...

SharedWorker compatibility in Chrome

Chrome supports SharedWorker from Chrome 4 on desktop, with the constructor on by default and no flag required. Chrome for Android does not support SharedWorker on any version, so any mobile coverage on Android Chrome needs a Service Worker or BroadcastChannel fallback.

SharedWorker compatibility in Edge

Microsoft Edge supports SharedWorker from Edge 79 on Windows, macOS, and Linux, the version that switched Edge to the Chromium engine. Edge 12 to 78 ran on EdgeHTML and did not include the SharedWorker constructor, so enterprise Windows fleets on Edge Legacy still need a fallback.

SharedWorker compatibility in Firefox

Firefox supports SharedWorker from Firefox 29 on desktop and Firefox for Android from version 33. Every Firefox release since Firefox 29 ships the API on by default, including Firefox ESR builds used in long-support enterprise environments.

SharedWorker compatibility in Safari

Safari supports SharedWorker from Safari 16 on macOS and iOS Safari 16 on iPhone and iPad. WebKit briefly shipped support in Safari 5 and 6, then removed it in Safari 6.1, so any site that still sees iOS 15 or macOS Monterey traffic needs a polyfill or a degraded fallback path.

SharedWorker compatibility in Opera

Opera supports SharedWorker from Opera 10.6 on desktop. Coverage tracks Chromium because every Opera build since Opera 15 is Chromium-based, so Opera GX inherits the same support window. Opera Mini does not support SharedWorker because its server-rendered model never runs worker scripts on the device.

SharedWorker compatibility in Samsung Internet

Samsung Internet shipped SharedWorker only in Samsung Internet 4.0 and 4.4. Every Samsung Internet release from 5.0 onward dropped support to align with Chromium for Android, which itself does not include SharedWorker. Galaxy phones on the current Samsung Internet build need a fallback.

SharedWorker compatibility in Android Browser

The legacy stock Android Browser, frozen at Android 4.4, does not support SharedWorker on any version. WebView on Android tracks Chrome for Android, so embedded WebView pages do not get the SharedWorker constructor either. Apps that need shared cross-context coordination on Android should reach for a Service Worker or BroadcastChannel.

SharedWorker compatibility in Internet Explorer

Internet Explorer never added SharedWorker support. IE 5.5 through IE 11 reach the page without the SharedWorker constructor, so feature detection must fall back to a dedicated Worker plus localStorage events. Microsoft has retired Internet Explorer, and IE traffic is now a small slice of enterprise Windows fleets.

Note

Note: SharedWorker breaks across mobile Chromium, older Safari, and Internet Explorer. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!

What are the key features of SharedWorker?

SharedWorker gives JavaScript a single shared background script per origin, with port-based communication, structured-clone payloads, and a runtime that outlives any individual tab.

  • Single instance per origin: A SharedWorker constructed with the same script URL and name returns one process for the whole origin. Tab A and tab B both get a port into the same script.
  • MessagePort communication: Each connecting page gets its own MessagePort on .port. The worker exposes the connect event, so it can route messages back to a specific tab.
  • Structured cloning: Payloads can include strings, numbers, arrays, plain objects, Maps, Sets, ArrayBuffers, and Blobs. Functions, DOM nodes, and class prototypes do not survive the clone.
  • Module worker support: Chromium, Firefox, and modern Safari accept new SharedWorker(url, { type: 'module' }), so the worker script can use static import instead of importScripts.
  • Same-origin scope: The browser only allows connections from contexts that share the worker's origin. A worker on app.example.com cannot be reached from payments.example.com.
  • Port-driven lifetime: A SharedWorker stays alive while any port is open. Calling port.close on every tab tells the browser it can tear down the worker process and reclaim memory.
  • Inspectable in DevTools: Chrome surfaces shared workers at chrome://inspect/#workers and Firefox lists them in about:debugging, so a single console can attach to the shared script.

Feature-detect the constructor before you reach for it; the snippet below ships in production code on browsers that lack the API:

// Feature detect SharedWorker before constructing one.
if (typeof SharedWorker !== 'undefined') {
    const worker = new SharedWorker('/shared-counter.js', { name: 'counter' });

    worker.port.start();

    worker.port.postMessage({ type: 'increment' });

    worker.port.onmessage = (event) => {
        console.log('Counter is now:', event.data.count);
    };
} else {
    console.warn('SharedWorker not supported. Falling back to a dedicated Worker plus BroadcastChannel.');
}

What are the common use cases of SharedWorker?

Web apps reach for SharedWorker any time multiple tabs need to share one expensive resource or one source of truth without round-tripping through a server.

  • Single WebSocket per origin: A SharedWorker holds one WebSocket connection that every open tab subscribes to. The server sees one client instead of one per tab, which keeps fan-out costs predictable.
  • Shared SQLite or IndexedDB writer: Database libraries like wa-sqlite and absurd-sql route every tab through one SharedWorker so writes do not collide and the page cache stays warm across tabs.
  • Cross-tab event bus: A SharedWorker can re-broadcast events to every connected port, which gives apps a tab-scoped pub/sub bus without depending on BroadcastChannel.
  • Centralized analytics queue: Tabs hand off impression and event payloads to one SharedWorker, which batches and ships them in one request, reducing duplicate beacon traffic.
  • Long-lived auth and refresh-token logic: One SharedWorker handles silent refresh, so a hundred open tabs share one token-rotation flow instead of racing the same /refresh endpoint.
  • Cached JSON warehouse: A SharedWorker fetches and caches large JSON blobs once and serves them to every tab, which speeds up dashboards that re-mount frequently.
...

How does SharedWorker differ from Web Worker and Service Worker?

SharedWorker, dedicated Web Worker, and ServiceWorker all run JavaScript off the main thread, but they differ on who can connect, how the runtime is scoped, and what guarantees the browser offers about lifetime. The table below lays out the trade-offs that drive the choice in production code.

DimensionSharedWorkerWeb Worker (Dedicated)Service Worker
Connection scopeMany same-origin pages share one instanceOne owning tab or workerMany same-origin pages, plus network interception
CommunicationMessagePort per connecting pagepostMessage from the owning contextpostMessage and fetch event interception
Global scopeSharedWorkerGlobalScopeDedicatedWorkerGlobalScopeServiceWorkerGlobalScope
LifetimeLives while any port is openDies when the owning tab closesPersists across tabs, browser-managed
Network interceptionNoNoYes, intercepts requests from controlled clients
Browser supportChrome 4+, Firefox 29+, Safari 16+; not on Android ChromeAll modern browsers and Internet Explorer 10+Chrome 40+, Firefox 44+, Safari 11.1+; not in Internet Explorer
Best fitOne shared resource across tabsHeavy CPU work for one tabOffline cache, push, request routing

What are the known issues with SharedWorker?

SharedWorker has been in browsers for over a decade, but production code still has to plan around uneven mobile support, debugging gaps, and a handful of WHATWG-spec constraints.

  • No support on Android Chrome or Samsung Internet: Mobile Chromium dropped SharedWorker and never re-added it. Apps that must cover mobile users need a Service Worker or BroadcastChannel fallback.
  • No blob URLs: SharedWorker does not accept blob: URLs as the script source on most browsers, so bundlers that ship workers as inline blobs need a separate code path for SharedWorker.
  • DevTools logging is split: Console logs from inside a SharedWorker do not appear in the page's DevTools panel. Chrome surfaces them under chrome://inspect/#workers and Firefox uses about:debugging, so new developers often think the worker is silent.
  • Vite and same-origin policy: Vite's dev server rewrites worker URLs in a way that breaks SharedWorker. Production builds work, but dev mode needs a workaround that serves the worker script from a sibling route.
  • MDN example only fans out to one client: The canonical MDN snippet handles the connect event but only stores the most recent port. Real apps have to keep an array of every connecting port and broadcast to all of them.
  • Module worker support is recent: The { type: 'module' } option only works on Chromium since Chrome 80, Firefox 114, and Safari 16. Older browsers parse the option as a name string, which silently changes behavior.
  • Worker death on idle: The browser is allowed to kill an idle SharedWorker after every page closes. State that needs to survive a tab close must persist to IndexedDB or the server before the last port disconnects.

In my experience, the most common production bug is assuming the SharedWorker survives a hard reload. The browser tears it down the moment the last connected port closes, so any in-memory cache, WebSocket subscription, or unflushed analytics batch is gone. Persist anything important to IndexedDB before the last tab disconnects.

...

Citations

All SharedWorker version numbers and platform notes in this guide come from these primary sources:

Author

Prince Dewani is a Community Contributor at TestMu AI, where he manages content strategies around software testing, QA, and test automation. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI. Prince has also presented academic research at the international conference PBCON-01. He further specializes in on-page SEO, bridging marketing with core testing technologies. On LinkedIn, he is followed by 4,300+ QA engineers, developers, DevOps experts, tech leaders, and AI-focused practitioners in the global testing community.

Open in ChatGPT Icon

Open in ChatGPT

Open in Claude Icon

Open in Claude

Open in Perplexity Icon

Open in Perplexity

Open in Grok Icon

Open in Grok

Open in Gemini AI Icon

Open in Gemini AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Frequently asked questions

Did you find this page helpful?

More Related Hubs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests