The ServiceWorker interface of the ServiceWorker API provides a reference to a service worker. Multiple browsing contexts (e.g. pages, workers, etc.) can be associated with the same service worker, each through a unique ServiceWorker object.

Documentation ServiceWorker by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Variables

onstatechange:Function

An EventListener property called whenever an event of type statechange is fired; it is basically fired anytime the ServiceWorker.state changes.

read onlyscriptURL:String

Returns the ServiceWorker serialized script URL defined as part of ServiceWorkerRegistration. The URL must be on the same origin as the document that registers the ServiceWorker.

read onlystate:ServiceWorkerState

Returns the state of the service worker. It returns one of the following values: installing, installed, activating, activated, or redundant.

Methods

postMessage(message:Dynamic, ?transferable:Array<Dynamic>):Void

Throws:

null

DOMError

Inherited Variables

Inherited Methods

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError