v148 · JavaScript · demo
Persistent Counter
Both workers tick a counter every second. Disconnect all clients from the standard worker — it resets to zero. The extendedLifetime worker keeps counting.
Checking SharedWorker support…
Standard SharedWorker
0
disconnected
Counter resets when last client disconnects
SharedWorker with extendedLifetime: true
0
disconnected
Counter continues after last client disconnects
// Standard SharedWorker — terminated when last client closes
const standard = new SharedWorker(workerURL);
// Extended lifetime — survives after all clients disconnect (Chrome 148+)
const extended = new SharedWorker(workerURL, {
name: 'persistent-counter',
extendedLifetime: true,
});
see also
- Background Channel — worker as a persistent message queue
- Back to feature index
- ChromeStatus entry
implementation reference
Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗