DEV Community


Discussion on: Painless PWA

yne profile image
Rémy F. Author

<script src=sw.js></script> will not register the script as a Service Worker (running in a background thread).
You need to navigator.serviceWorker.register('/path/to/your/worker.js') for that.
I used <link rel="worker" href="sw.js"> because it allows me to give a relative URL, but get an absolute URL when accessing the href attribute.