How to use the workbox-window/Workbox.mjs.Workbox function in workbox-window

To help you get started, we’ve selected a few workbox-window examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github philipwalton / blog / assets / javascript / sw-init.js View on Github external
export const init = async () => {
  // Instantiating the Workbox instance adds an event listener to
  // `navigator.serviceWorker`, which will be undefined in older browsers.
  wb = new Workbox('/sw.js');

  addNavigationReportListener();
  addFirstInstalledListener();
  addCacheUpdateListener();
  addSWUpdateListener();

  const {log} = await import('./log');
  log.awaitBeforeSending(setSiteVersionOrTimeout());
  log.awaitBeforeSending(setNavigationCacheOrTimeout());

  // Calling register must happen after all presend dependencies get added.
  await wb.register();
};

workbox-window

Simplifies communications with Workbox packages running in the service worker

MIT
Latest version published 2 months ago

Package Health Score

97 / 100
Full package analysis