Please note that this is just my 2 cents to the service worker topic. It could be outdated, deprecated or overly complicated.
Files:
- The actual service worker (serviceworker.js)
- your existing JS on your page (e.g. main.js)
In main.js, the service worker gets installed like this:
const serviceWorkerUri = '/serviceworker-v1.9.js';