ServiceWorkerGlobalScope: install event

The install event of the ServiceWorkerGlobalScope interface is fired when a ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.installing worker.

Bubbles No
Cancelable No
Interface ExtendableEvent
Event handler property ServiceWorkerGlobalScope.oninstall


The following snippet shows how an install event handler can be used to populate a cache with a number of responses, which the service worker can then use to serve assets offline:

this.addEventListener('install', function(event) {
  event.waitUntil('v1').then(function(cache) {
      return cache.addAll([

You can also set up the event handler using the ServiceWorkerGlobalScope.oninstall property:

globalScope.oninstall = function(event) {


Service Workers 1
# service-worker-global-scope-install-event

Browser compatibility

BCD tables only load in the browser

See also