mirror of https://github.com/dirtbags/moth.git
19 lines
575 B
JavaScript
19 lines
575 B
JavaScript
function pwa_init() {
|
|
console.log("Starting service worker");
|
|
if ('serviceWorker' in navigator) {
|
|
navigator.serviceWorker.register("./sw.js").then(function(reg) {
|
|
console.log("Successfully registered service worker", reg);
|
|
}).catch(function(err) {
|
|
console.warn("Error while registering service worker", err);
|
|
});
|
|
} else {
|
|
console.log("Service workers not supported. Some offline functionality may not work");
|
|
}
|
|
}
|
|
|
|
if (document.readyState === "loading") {
|
|
document.addEventListener("DOMContentLoaded", pwa_init);
|
|
} else {
|
|
pwa_init();
|
|
}
|