MDN Web Docs

Syntax

js

waitUntil(promise)

Parameters

promise

A Promise that extends the lifetime of the event.

Return value

None (undefined).

Examples

Using waitUntil() within a service worker's install event:

js

addEventListener("install", (event) => {
  const preCache = async () => {
    const cache = await caches.open("static-v1");
    return cache.addAll(["/", "/about/", "/static/styles.css"]);
  };
  event.waitUntil(preCache());
});

Specifications

Specification
Service Workers Nightly
# dom-extendableevent-waituntil

Browser compatibility

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗