Can’t make the #ChromeDevSummit this year? Catch all the content (and more!) on the livestream, or join your peers for a CDS Extended event at a hosted location nearby. To learn more, check out the Chrome Dev Summit 2019 website.

Service Worker Checklist

This page contains a couple of tips that will ensure your users get the best experience from your web app as well as ensuring there aren't any hidden surprises while developing your site.

Register your service worker the right way

In general, you should wait for the window load event before registering your service worker. This will allow the browser to prioritize assets for the page and will prevent any risk of precaching interfering with the page.

if ('serviceWorker' in navigator) {
  window.addEventListener('load', function() {
    navigator.serviceWorker.register('/service-worker.js');
  });
}
DO: Wait until the `window` load event to register your service worker.

Learn More

This guide is a summary of common gotchas developers hit when starting out, but for more information check out the "Service Worker Registration" guide.