Wydajność

perf/bfcache-no-unload

No code listens to the unload event; use pagehide or visibilitychange so the page can use the back/forward cache.

umiarkowanastatycznefe-core-web-vitals

Dlaczego

With the back/forward cache, going back shows the page instantly with LCP, CLS and INP of a cached page. An unload listener makes Firefox skip the cache and Chrome is phasing the event out; unload also does not fire reliably on mobile, so the code it guards is lost anyway.

Poprawka

Move the work to pagehide (fires on every navigation away, cache or not) or to visibilitychange when document.visibilityState === 'hidden' (the last reliable moment on mobile). Send analytics with navigator.sendBeacon or fetch(…, { keepalive: true }). Check third-party scripts too: DevTools > Application > Back/forward cache lists what blocks it.

Przykłady

// bad
window.addEventListener('unload', sendStats)
// good
window.addEventListener('pagehide', sendStats)
document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'hidden') saveDraft() })

Źródła

Fakty

Identyfikator
perf/bfcache-no-unload
Waga
umiarkowana
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
html vue svelte astro jsx
Ten sam problem w
Lighthouse bf-cache
Uczy jej skill
fe-core-web-vitals Core Web Vitals
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

npx github:dawidolko/frontend-skills explain perf/bfcache-no-unload