ServiceWorker: don't wait for window.onload before registering the worker

This commit is contained in:
Alex Gleason 2023-11-20 14:22:48 -06:00
parent 8ba328d96b
commit df020e4253
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 1 additions and 3 deletions

View File

@ -1,9 +1,7 @@
/** Register the ServiceWorker. */
function registerSW(path: string) {
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register(path, { scope: '/' });
});
navigator.serviceWorker.register(path, { scope: '/' });
}
}