Skip to Content
Platform.Ontology

SharedWorker

A background script that all tabs of a site share, so one process keeps state across them.

Works without askingFiles and storageIn sessionWeb browsersWhile you use it

In one line

Can run one background script shared by all open tabs of the site

A background script that all tabs of a site share, so one process keeps state across them.

Lets a site keep one connection and a single cross-tab state, which also shows how many tabs the person has. Partitioned like other storage in modern browsers, so a tracker cannot join sites with it.

What it can and can't do

What the user does: Nothing. It happens while you have the site open in more than one tab.

It can

  • Keep one connection or one copy of data for all tabs
  • Do work away from the page so it stays smooth
  • Pass messages to each open tab

It cannot

  • Keep running after you close every tab of the site
  • Reach tabs from other sites
  • Change the page's content directly

How it differs between platforms: Most computer browsers support it. Chrome on Android and Samsung Internet only partly do.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported52010-05-25None
EdgeSupported792020-01-15None
FirefoxSupported292014-04-29None
SafariSupported162022-09-12None
Safari on iPhoneSupported162022-09-12None
Chrome on AndroidPartial1482026-05-05Support on Android arrived recently (verify)
Samsung InternetPartialNot availableNot listedUnverified

How a site asks for it

APInew SharedWorker(url)
Browser compat keysapi.SharedWorker
How access is grantednone
What the user seesNone
Needs a secure context (HTTPS)No
Needs a user gestureNo
How long it lastsWhile at least one connected page is alive
How to take it backClear site data, browser privacy settings
Inside an iframeNot listed

Data you get

What comes back: Port messages
Shape: event
How often: live

No individual data fields. The signal is the access itself.

Technical limits

  • Same origin and partition
  • Ends when the last page disconnects
  • Chrome on Android support came late (verify)

The story

What it is

A background script that every tab of a site shares, so one process keeps state across them.

For you

You never see it. It is why a chat site can keep one live connection for all your open tabs, saving battery and data.

For makers

It lets one connection or one heavy job serve every tab. Makers save servers and battery. It also means one hidden script can see what all tabs of the site do.

Where you see it

TypeExampleApps
messagingA web chat opens one live link for all tabs so you do not get duplicate messages.Slack
gamesA browser game that is open in two tabs keeps one network link and one game state.None named
productivityA web app does one background sync for all open tabs of a document.None named
shoppingA store keeps one live price feed shared across tabs.None named
liveA live score or stock page uses one feed shared across tabs.None named
analyticsA site script collects events from every tab in one place.None named

Risks

  • Hidden background code
  • Safari support is recent

What the platform says

  • MDN: SharedWorker. Documents a script that runs in the background and can be used by many tabs of the same site.

Good uses and abuse

Legitimate uses

  • Shared connection, cross-tab coordination

Known abuse

  • Cross-site state hub before partitioning

Scores

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility3 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bitsNot ratedRough identifying entropy, when known

History

  • 2022-09, Safari 16: Shipped in Safari
  • 2023-07, Chrome 115: Partitioned by top level site
  • BroadcastChannel. Can send messages between open tabs and frames of the same site

Sources

How well checked: Based on official documentation.

On this page