Step-by-step introduction to the Service Worker API.
Use the ServiceWorker as a progressive enhancement. Meaning only try to use one after you've tested it's available as a feature.
// in page.html
if ('serviceWorker' in navigator) {
console.log('ServiceWorker is supported. Let\'s use it.');
} else {
console.log('ServiceWorker is not supported');
}