DEV Community

Discussion on: Painless PWA

Collapse
 
bayuangora profile image
Bayu Angora • Edited

What is the difference (pros / cons) between link rel="worker" and script src="worker" implementation?

Collapse
 
yne profile image
Rémy F.

<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.