mirror of https://github.com/dirtbags/moth.git
18 lines
460 B
JavaScript
18 lines
460 B
JavaScript
function pwa_init() {
|
|
if ('serviceWorker' in navigator) {
|
|
navigator.serviceWorker.register("./sw.js").then(function(reg) {
|
|
})
|
|
.catch(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()
|
|
}
|