So from what I tested on Android Chrome, the
load event seems to only fire when the page is first loaded into a new tab. Once the tab has been loaded, the
load event doesn’t fire until I close the tab and create a new one. Not sure if that is the intended behavior that the Chrome team wanted, perhaps we should check with them on this.
It was what the ServiceWorker guide from Google recommended when I was reading through the guide a few months back.
A simple rule of thumb would be to delay registration until after the
load event fires on
window , like so
We can definitely do without it but that does mean we have to be sure that whatever is happening in the initializer does not affect the page load time significantly.