pkg/pwa/static/pwa.js 570 B raw
1
// Registers the shared andromeda service worker. Included by app templates
2
// as <script src="/pwa.js" defer></script>.
3
//
4
// Note: service workers require a secure context (https, or localhost).
5
// Registration over plain http on a LAN IP will fail — it is logged to the
6
// console rather than thrown so production users aren't spammed.
7
if ('serviceWorker' in navigator) {
8
  window.addEventListener('load', () => {
9
    navigator.serviceWorker
10
      .register('/sw.js')
11
      .catch((err) => console.warn('service worker registration failed:', err.message));
12
  });
13
}