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.

cold SW (no preload)
280 ms
warm SW (default)
160 ms
autopreload (browser mode)
80 ms
// 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