ServiceWorkerGlobalScope: activate event

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

This event is not cancelable and does not bubble.


Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener('activate', event => { });

onactivate = event => { };

Event type

Event properties

Doesn't implement any specific properties, but inherits properties from its parent, Event.


The following snippet shows how you could use an activate event handler to upgrade a cache.

globalScope.addEventListener('activate', function(event) {
  var cacheAllowlist = ['v2'];

    caches.forEach(function(cache, cacheName) {
      if (cacheAllowlist.indexOf(cacheName) == -1) {
        return caches.delete(cacheName);

You can also set up the event handler using the onactivate property:

globalScope.onactivate = function(event) {


Service Workers 1
# service-worker-global-scope-activate-event
Service Workers 1
# dom-serviceworkerglobalscope-onactivate

Browser compatibility

BCD tables only load in the browser

See also