WorkerNavigator: serviceWorker property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Note: This feature is only available inWeb Workers.
TheserviceWorker read-only property of theWorkerNavigator interface returns theServiceWorkerContainer object for theassociated document, which provides access to registration, removal, upgrade, and communication with theServiceWorker.
The feature may not be available in private mode.
In this article
Value
Examples
This code checks if the browser supports using service worker in workers.
js
if ("serviceWorker" in navigator) { // Supported!}Specifications
| Specification |
|---|
| Service Workers Nightly> # navigator-serviceworker> |