Service Worker Introduction

Step-by-step introduction to the Service Worker API.

Feature detection

Use the ServiceWorker as a progressive enhancement. Meaning only try to use one after you've tested it's available as a feature.

Code

// in page.html
if ('serviceWorker' in navigator) {
  console.log('ServiceWorker is supported. Let\'s use it.');
} else {
  console.log('ServiceWorker is not supported');
}

Output