Navigator.serviceWorker
The Navigator.serviceWorker read-only property returns the ServiceWorkerContainer object for the associated document, which provides access to registration, removal, upgrade, and communication with the ServiceWorker.
The feature may not be available in private mode.
Syntax
const workerContainerInstance = navigator.serviceWorker;
Value
Examples
This code checks if the browser supports service workers.
if ('serviceWorker' in navigator) { // Supported! }
Specifications
| Specification |
|---|
| Service Workers 1 # navigator-service-worker-attribute |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
serviceWorker |
40 |
17 |
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
|
No |
27 |
11.1 |
40 |
40 |
44 |
27 |
11.3 |
4.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/serviceWorker