1
0
Fork 0
mirror of https://github.com/dirtbags/moth.git synced 2025-01-05 03:21:06 -07:00
moth/theme/moth-pwa.js
int00h5525 1ea739207b
Apply suggestions from code review
Co-Authored-By: Neale Pickett <neale@woozle.org>
2019-11-07 13:25:48 -06:00

17 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()
}