caching-configs.register.js

if ('serviceWorker' in navigator) {
  window.addEventListener('load', async () => {
    // NOTE: swName is script name for bundle generated in webpack,
    // relative to build folder path
    const swName = `./caching-configs.sw.js`;
    const options = { scope: './' };
    navigator.serviceWorker.register(swName, options).then(
      function (registration) {
        // This is under browser. Can detect webp support.
        console.log('Service worker registeration successful', registration);
      },
      function (err) {
        console.log('ServiceWorker registration failed: ', err);
      }
    );
  });
}