Skip to content

fix(api): remove outdated Firefox beforeunload bfcache claims - #46218

Merged
hamishwillee merged 5 commits into
mdn:mainfrom
BaconMan1168:fix/firefox-beforeunload-bfcache
Oct 25, 2026
Merged

hamishwillee merged 5 commits into
mdn:mainfrom
BaconMan1168:fix/firefox-beforeunload-bfcache

Conversation

@BaconMan1168

Copy link
Copy Markdown
Contributor

Description

This PR removes the claim that Firefox won't put pages with beforeunload listeners in the bfcache, along with the same claim on the sendBeacon() and pagehide pages.

Motivation

  • The beforeunload usage notes said Firefox excludes pages with beforeunload listeners from the bfcache. Firefox has allowed these pages in the bfcache since version 116, so I removed the bullet. That left a one-item list, so I turned it into a paragraph. I also removed the sentence saying that listening sparingly minimizes the effect on performance, since the removed bullet was the only reason given for it.
  • The "Legacy events" section of the sendBeacon() page had a separate line saying Firefox excludes pages with beforeunload handlers, which I removed. The comparison with pagehide now only mentions unload.
  • The pagehide page said pagehide is compatible with the bfcache "unlike the unload and beforeunload events". It now only mentions unload.

Additional details

  • Firefox bugs: 1837045 (enabled in release, Firefox 116) and 1741671 (enabled in Nightly).
  • The docshell.shistory.bfcache.ship_allow_beforeunload_listeners pref now defaults to true on all platforms in Firefox's current source.
  • markdownlint-cli2 and prettier --check report 0 issues on the changed files, and the front-matter linter passes.

Related issues and pull requests

Fixes #46214

@BaconMan1168
BaconMan1168 requested a review from a team as a code owner October 21, 2026 00:25
@BaconMan1168
BaconMan1168 requested review from hamishwillee and removed request for a team October 21, 2026 00:25
@github-actions github-actions Bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Preview URLs (3 pages)

External URLs (2)

URL: /en-US/docs/Web/API/Window/beforeunload_event
Title: Window: beforeunload event


URL: /en-US/docs/Web/API/Window/pagehide_event
Title: Window: pagehide event

(comment last updated: 2026-10-25 22:38:49)

Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
Co-authored-by: Hamish Willee <hamishwillee@gmail.com>
- Only show a generic browser-specified string in the displayed dialog. This cannot be controlled by the webpage code.

The `beforeunload` event suffers from some problems:
The `beforeunload` event is not reliably fired, especially on mobile platforms. For example, the event is not fired in the following scenario:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
The `beforeunload` event is not reliably fired, especially on mobile platforms. For example, the event is not fired in the following scenario:
The `beforeunload` event is not reliably fired, especially on mobile platforms. For example, the event is not fired in the following scenario:
hamishwillee and others added 2 commits October 26, 2026 09:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@hamishwillee hamishwillee left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much!

@hamishwillee
hamishwillee merged commit 9587997 into mdn:main Oct 25, 2026
9 checks passed
wbamberg added a commit to wbamberg/content that referenced this pull request Oct 26, 2026
* origin/fix-42136:
  Update clipboard docs for Chrome 157 service worker support (mdn#46202)
  FF159 Relnote: WebGL EXT_clip_control, EXT_texture_mirror_clamp_to_edge, EXT_texture_norm16  (mdn#46262)
  Update Firefox 159 release notes for WebDriver conforming changes (mdn#46265)
  Move `core-js` links to website docs (mdn#46259)
  BigInt.asIntN: Fix comment to reflect actual I64_CEIL value (mdn#46255)
  Container Timing API (mdn#45564)
  fix(api): remove outdated Firefox beforeunload bfcache claims (mdn#46218)
  Fix numbers of `<rect>` elements in examples (mdn#46256)
  Add missing `PlatformArch` values (mdn#43847)
  Update InterfaceData based on WebRef (mdn#46254)
  Fix memory management code sample and comment wording (mdn#46252)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

2 participants