[buddypress-trac] [BuddyPress Trac] #9299: Unload event handler in buddypress-notifications.js breaks bfcache
buddypress-trac
noreply at wordpress.org
Fri Dec 26 02:27:19 UTC 2025
#9299: Unload event handler in buddypress-notifications.js breaks bfcache
-------------------------------------+---------------------
Reporter: westonruter | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 15.0.0
Component: Toolbar & Notifications | Version: 3.0.0
Severity: normal | Resolution:
Keywords: |
-------------------------------------+---------------------
Comment (by vapvarun):
Attaching a patch that replaces the `unload` event with `pagehide` in
`buddypress-notifications.js`.
'''The Change:'''
{{{
// Before
$( window ).on( 'unload', this.resetFilter );
// After
$( window ).on( 'pagehide', this.resetFilter );
}}}
'''Why This Matters:'''
* The `unload` event is deprecated and will be removed from Chrome
* Using `unload` makes pages ineligible for bfcache (back/forward cache)
* `pagehide` is the modern replacement that allows bfcache to work
properly
* WordPress core made the same change in
[https://core.trac.wordpress.org/ticket/55491 #55491]
'''Testing:'''
Verified on a local BuddyPress 15.0.0-alpha installation:
* Confirmed `pagehide` event handler is registered (1 handler)
* Confirmed `unload` event handler is NOT registered (0 handlers)
* Confirmed `resetFilter()` function works correctly - filter value
resets from 5 to 0
* Notifications page loads and functions normally
The functionality remains identical - the filter is still reset when
leaving the page.
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9299#comment:2>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list