demo · v140
Timing Comparator
Three navigation paths into the same page: cold SW startup, warm SW, autopreload-browser-mode. The bars show the time-to-first-byte each one delivers. Browser-mode autopreload fires the network request in parallel with the SW boot, recovering the SW startup tax.
// In the service worker bootstrap:
self.registration.navigationPreload?.enable();
self.registration.serviceWorker?.setAutopreloadMode("browser");
// browser : the UA decides which sub-resources to preload eagerly
// manual : the page tells the SW what to preload via a header
// off : opt out
see also
- SW autopreload browser mode — feature index
- Static routing & autopreload