Skip to content

Commit

Permalink
not everyone supports preload, #75061
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jul 9, 2019
1 parent acacc45 commit 7fdb996
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

// trigger service worker updates
const _tag = 'e4d8e56a-394f-4541-b817-421b1e2feed1';
const _tag = '586d4b79-f5c4-4aff-9a14-2139ddfbb486';

(function () {

Expand Down Expand Up @@ -38,12 +38,7 @@ const _tag = 'e4d8e56a-394f-4541-b817-421b1e2feed1';
return value;
}
// try the network (prefetch or fetch)
const res = await event.preloadResponse;
if (res) {
return res;
} else {
return fetch(event.request);
}
return event.preloadResponse || fetch(event.request);
}));
});
self.addEventListener('install', (event: any) => {
Expand All @@ -53,7 +48,9 @@ const _tag = 'e4d8e56a-394f-4541-b817-421b1e2feed1';
self.addEventListener('activate', (event: any) => {

event.waitUntil((async () => {
await (self as any).registration.navigationPreload.enable(); // Enable navigation preloads!
if ((self as any).registration.navigationPreload) {
await (self as any).registration.navigationPreload.enable(); // Enable navigation preloads!
}
await (self as any).clients.claim(); // Become available to all pages
})());
});
Expand Down

0 comments on commit 7fdb996

Please sign in to comment.