Service Workers in 5 Minutes

What is a service worker?

What is a service worker?

  • Background task
  • JS file that acts as a proxy server
  • Intercepts and modifies requests

Service Worker Requirements

  • Site must be served over HTTPS
  • Browser must have the Service Worker API available

Demographics: narrow af

Why would I want this tho?

Why would I want this tho?

Getting Started

with Workbox

Registering a service worker

                                if(navigator.serviceWorker) {
    navigator.serviceWorker.register('/sw.js')
        .catch(function(err) {
            console.error('Unable to register service worker.', err);
      });
}

Demo