ConstRegister the Service Worker. No-op in environments that don't support Service Workers.
Optionaloptions: { path?: string; scope?: string } = {}
Optionalpath?: stringScript path. ⚠️ No caller sets
this parameter: it documented a second worker (sw.js) that
never existed in this repo.
Optionalscope?: stringSW scope
Is a newer version of the application installed, that this page has not been reloaded onto?
true in two cases: a new worker WAITS behind the one holding the page, or it already
took the page because the update was applied from another tab. false for a first
install, before register() has resolved, and where service workers do not exist.
Whether SWRegister.applyUpdate has something to apply.
Applies the update the user accepted: the waiting worker takes the page, and the page RELOADS once it holds it — its own code is the old version's.
⚠️ The reload is not immediate, and it is not optional: it follows the change of controller, which the worker answers with. Reloading before would boot the old version again. A browser lets the new worker take over once the previous one has no request left in flight — measured: a previous worker waiting on slow tiles held the gesture for more than thirty seconds. Where the update was already applied from another tab, nothing waits any more and the page reloads at once.
true when an update is being applied — the page WILL reload; false when
nothing was waiting, and nothing happens.
Worker script path. Only one exists in this repo:
sw-core.js.