Clarify end-of-session event guidance for sendBeacon() - #45081
Conversation
|
Preview URLs (1 page) (comment last updated: 2026-08-12 18:22:28) |
|
Reading this back I think we also ought to expand a bit on
I wonder if we also ought to acknowledge the problem with I'd also be happy if @philipwalton would like to confirm that this is still the best guidance for developers. |
Remove the obsolete pagehide fallback and explain both its reliability limits and the broader visibilitychange trigger. Signed-off-by: 陳廷安 <73953029+nrps9909@users.noreply.github.com>
df4ac26 to
005c35b
Compare
|
Thanks, this makes the guidance clearer. I updated the previous section to note that visibilitychange also fires when the user switches tabs, and added an explicit explanation that pagehide is bfcache-compatible but still unreliable for end-of-session analytics. I kept the existing heading so the published #avoid_unload_and_beforeunload fragment does not break. The branch is rebased and the focused pre-commit, URL/xref, formatting, Markdown lint, front matter, and spelling checks pass. |
|
I think my version of the last paragraph here is better. |
Description
Motivation
All modern browsers implement visibilitychange, so recommending pagehide as a compatibility fallback is no longer necessary. The expanded guidance makes both the visibilitychange caveat and the remaining pagehide limitation explicit.
Validation
The focused file passes the repository pre-commit hook, URL and changed-xref checks, front matter validation, Prettier, Markdownlint, cSpell, and git diff checking.
Related issues and pull requests
Fixes #44927