Context
Related to #44927 ("Is 'Use pagehide as a fallback' clause still needed?").
The current "Use pagehide as a fallback" section says:
To support browsers which don't implement visibilitychange, use the pagehide event.
All modern browsers implement visibilitychange today, so a reader (as in #44927) reasonably wonders whether the pagehide fallback is obsolete.
Why the fallback is still valid
The real, still-relevant reason to also listen for pagehide is reliability / idempotency, not missing visibilitychange support:
visibilitychange fires on every transition to hidden (e.g. switching tabs, minimizing the window), so the handler can run multiple times in a session.
pagehide fires a single time as the document is being unloaded, making it the natural place for a final, fire-and-forget sendBeacon() call.
So pagehide remains a useful complement to visibilitychange, not a legacy shim.
Proposal
Add a short note under "Use pagehide as a fallback" clarifying that pagehide is recommended because it fires once at unload (whereas visibilitychange can fire repeatedly), so it provides a single reliable final beacon in addition to visibilitychange.
I'm happy to submit a PR for this.
Context
Related to #44927 ("Is 'Use pagehide as a fallback' clause still needed?").
The current "Use pagehide as a fallback" section says:
All modern browsers implement
visibilitychangetoday, so a reader (as in #44927) reasonably wonders whether thepagehidefallback is obsolete.Why the fallback is still valid
The real, still-relevant reason to also listen for
pagehideis reliability / idempotency, not missingvisibilitychangesupport:visibilitychangefires on every transition tohidden(e.g. switching tabs, minimizing the window), so the handler can run multiple times in a session.pagehidefires a single time as the document is being unloaded, making it the natural place for a final, fire-and-forgetsendBeacon()call.So
pagehideremains a useful complement tovisibilitychange, not a legacy shim.Proposal
Add a short note under "Use pagehide as a fallback" clarifying that
pagehideis recommended because it fires once at unload (whereasvisibilitychangecan fire repeatedly), so it provides a single reliable final beacon in addition tovisibilitychange.I'm happy to submit a PR for this.