-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
40 lines (26 loc) · 1.13 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
title: "WorkerNavigator: serviceWorker property"
short-title: serviceWorker
slug: Web/API/WorkerNavigator/serviceWorker
page-type: web-api-instance-property
browser-compat: api.WorkerNavigator.serviceWorker
---
{{securecontext_header}}{{APIRef("Service Workers API")}}{{AvailableInWorkers}}
The **`serviceWorker`** read-only property of the {{domxref("WorkerNavigator")}} interface returns the {{domxref("ServiceWorkerContainer")}} object for the [associated document](https://html.spec.whatwg.org/multipage/browsers.html#concept-document-window), which provides access to registration, removal, upgrade, and communication with the {{domxref("ServiceWorker")}}.
The feature may not be available in private mode.
## Value
{{domxref("ServiceWorkerContainer")}}.
## Examples
This code checks if the browser supports using service worker in workers.
```js
if ("serviceWorker" in navigator) {
// Supported!
}
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("Service Worker API", "", "", "nocode")}}
- [Using Service Workers](/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers)