1 2 3 4 5
if ("serviceWorker" in navigator) { navigator.serviceWorker.register("/sw.js") .then(() => {}) .catch((err) => console.log("Service worker registration failed", err)); }