refactor: Simplify prefetch by moving to activate event

Remove message-based prefetch in favor of prefetching on activate:
- Remove PREFETCH_ASSETS message listener from service worker
- Remove prefetchAssets() call and idle callback from pushHelper.js
- Call prefetchAssets() directly in activate event

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Pranav
2026-01-10 21:14:35 -08:00
co-authored by Claude Opus 4.5
parent 6d3d76982a
commit b345826566
2 changed files with 1 additions and 28 deletions
+1 -13
View File
@@ -122,12 +122,7 @@ self.addEventListener('install', () => self.skipWaiting());
self.addEventListener('activate', event => {
event.waitUntil(
Promise.all([
// Clean up stale assets not in current manifest
cleanupStaleAssets(),
// Take control of all clients
self.clients.claim(),
])
Promise.all([cleanupStaleAssets(), prefetchAssets(), self.clients.claim()])
);
});
@@ -164,10 +159,3 @@ async function cleanupStaleAssets() {
await Promise.all(deletions);
}
self.addEventListener('message', async event => {
if (event.data?.type === 'PREFETCH_ASSETS') {
await prefetchAssets();
event.ports[0]?.postMessage({ type: 'PREFETCH_COMPLETE' });
}
});