What is the proper way to delay a service worker update check?

I’d like to only have the service worker update check occur eg 5 mins into the app being used. Problem is that because it’s wrapped in window.addEventListener(‘load’, async () => { navigator.serviceWorker.register("/serviceWorker.js"); const registration = await navigator.serviceWorker.getRegistration(); it starts its checks at load time. To get around it I put the service worker init in… Read More What is the proper way to delay a service worker update check?

Can't pass data to serviceWorker once it's registered as it's null

I’m new with serviceWorker and trying to pass data to it after it’s registered a way like navigator.serviceWorker.register(‘/serviceWorker.js’).then(function () { navigator.serviceWorker.controller.postMessage({‘hello’: ‘world’}); }); But I receive the error Cannot read properties of null (reading ‘postMessage’) >Solution : You can wait until service worker is ready and then post a message like this : if (navigator.serviceWorker)… Read More Can't pass data to serviceWorker once it's registered as it's null