unload listener

bp/unload-listenerwarningperformancelighthouse

Why it matters

An unload handler keeps the page out of the back/forward cache and often never fires on mobile (Lighthouse: page prevented back/forward cache restoration).

Fix

Listen for pagehide or visibilitychange instead.

Credit

  • From Google Chrome

    web.dev documents that unload handlers make pages ineligible for the back/forward cache.

References