mirror of
https://github.com/zoldar/jenot.git
synced 2026-01-03 06:22:55 +00:00
23 lines
634 B
JavaScript
23 lines
634 B
JavaScript
const registerServiceWorker = async () => {
|
|
if ("serviceWorker" in navigator) {
|
|
try {
|
|
const registration = await navigator.serviceWorker.register(
|
|
"/js/caching-worker.js",
|
|
{
|
|
scope: "/",
|
|
},
|
|
);
|
|
if (registration.installing) {
|
|
console.log("Service worker installing");
|
|
} else if (registration.waiting) {
|
|
console.log("Service worker installed");
|
|
} else if (registration.active) {
|
|
console.log("Service worker active");
|
|
}
|
|
} catch (error) {
|
|
console.error(`Registration failed with ${error}`);
|
|
}
|
|
}
|
|
};
|
|
|
|
registerServiceWorker();
|