Skip to content

Clarify why pagehide is still recommended as a fallback in Navigator.sendBeacon #44942

Description

@wjs-tech

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions