--- title: ServiceWorkerRegistration.active slug: Web/API/ServiceWorkerRegistration/active translation_of: Web/API/ServiceWorkerRegistration/active ---
The active
property of the {{domxref("ServiceWorkerRegistration")}} interface returns a service worker whose {{domxref("ServiceWorker.state")}} is activating
or activated
. This property is initially set to null
.
An active worker controls a {{domxref("ServiceWorkerClient")}} if the client's URL falls within the scope of the registration (the scope
option set when {{domxref("ServiceWorkerContainer.register")}} is first called.)
Note: This feature is available in Web Workers.
sw = ServiceWorker.active
A {{domxref("ServiceWorker")}} object, if it is currently in an activating
or activated
state.
Specification | Status | Comment |
---|---|---|
{{SpecName('Service Workers', '#service-worker-registration-active-attribute', 'ServiceWorkerRegistration.active')}} | {{Spec2('Service Workers')}} | Initial definition. |