Skip to content

Extended lifetime shared workers #492

@domenic

Description

@domenic

WebKittens

@annevk @youennf

Title of the proposal

Extended lifetime shared workers

URL to the spec

whatwg/html#10997 (no spec PR quite yet)

URL to the spec's repository

https://github.com/whatwg/html

Issue Tracker URL

No response

Explainer URL

https://gist.github.com/domenic/c5bd38339f33b49120ae11b3b4af5b9b#file-1-explainer-md

TAG Design Review URL

w3ctag/design-reviews#1089

Mozilla standards-positions issue URL

mozilla/standards-positions#1227

WebKit Bugzilla URL

No response

Radar URL

No response

Description

We propose adding a new option to the SharedWorker constructor that serves as a request to extend its lifetime after all current clients have unloaded:

const sharedWorker = new SharedWorker(url, { extendedLifetime: true });

The primary use case here is to allow pages to perform some async work that requires JavaScript after a page unloads, without needing to rely on a service worker.

Since @annevk mentioned WebKit has some trepidation about the existing extended lifetime service workers, let me emphasize a point from the explainer that we intend this new feature to provide parity with such service workers, and not give any capabilities beyond. For example, if WebKit decided to shut down all service workers for non-running pages, they would also do so for these shared workers.

The main motivation here is to reduce redundant service worker (ab)use that people currently have to resort to for this sort of work. (And which we've seen evidence of in the wild.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions