Namespaces

Methods

clientsClaim

static

clientsClaim()

Claim any currently available clients once the service worker becomes active. This is normally used in conjunction with skipWaiting().

loadModule

static

loadModule(moduleName)

Load a Workbox module by passing in the appropriate module name.

This is not generally needed unless you know there are modules that are dynamically used and you want to safe guard use of the module while the user may be offline.

Parameter

moduleName

string

setConfig

static

setConfig(options)

Updates the configuration options. You can specify whether to treat as a debug build and whether to use a CDN or a specific path when importing other workbox-modules

Parameter

options

Optional

Object

Values in options have the following properties:

Parameter

debug

Optional

boolean

If true, dev builds are using, otherwise prod builds are used. By default, prod is used unless on localhost.

modulePathPrefix

Optional

function()

To avoid using the CDN with workbox-sw set the path prefix of where modules should be loaded from. For example modulePathPrefix: '/third_party/workbox/v3.0.0/'.

modulePathCb

Optional

workbox~ModulePathCallback

If defined, this callback will be responsible for determining the path of each workbox module.

skipWaiting

static

skipWaiting()

Force a service worker to become active, instead of waiting. This is normally used in conjunction with clientsClaim().

Abstract type

ModulePathCallback

inner

ModulePathCallback(moduleName, debug) returns string

A ModulePathCallback function can be used to modify the modify the where Workbox modules are loaded.

Parameter

moduleName

string

The name of the module to load (i.e. 'workbox-core', 'workbox-precaching' etc.).

debug

boolean

When true, dev builds should be loaded, otherwise load prod builds.

Returns

string This callback should return a path of module. This will be passed to importScripts().