Chrome Has Switched Off unload: What Breaks and How to Fix It

Chrome spent most of 2026 switching off the unload event. The rollout went by percentage of page loads, starting at 1% in March and reaching 100% on 22 September. If your application saves state, releases a lock, notifies a server or signals another window from an unload handler, there’s now a good chance the handler never fires. Nothing fails in your deploy or your tests. The only visible trace is a console message most users will never open the DevTools to see:
[Violation] Permissions policy violation: unload is not allowed in this document.We hit this ourselves. One of our applications opens a separate tab for a short-lived task, and the main window used the child’s unload event to know the task was finished and the tab had closed. It stopped working on some machines, some of the time. While the rollout was in progress, the same build of an application could behave differently for different users on the same Chrome version. Since Chrome 154 the behaviour is consistent: the handler doesn’t run for anyone.
Below: what’s changing and when, how to check whether you’re affected (many teams aren’t), and the jobs developers have given unload over the years, with a replacement for each. There’s no single drop-in substitute. The right fix depends on what the handler was doing.
What’s actually happening, and the exact timeline
Chrome is not deleting the unload event. It’s flipping the default of a Permissions-Policy from allow to deny. The event still exists in the platform, pages can explicitly opt back in (more on that below), and Chrome says it plans to support the opt-out “for the considerable future”. What changes is that by default, addEventListener('unload', ...) registers a handler that never runs.
The default flip was rolled out by percentage of page loads, which is why the breakage felt random while it was in progress: the same user could see both behaviours in the same week.
| Chrome version | Date | Page loads with unload disabled |
|---|---|---|
| 146 | 10 March 2026 | 1% |
| 147 | 7 April 2026 | 5% |
| 148 | 5 May 2026 | 10% |
| 149 | 2 June 2026 | 20% |
| 150 | 30 June 2026 | 40% |
| 151 | 28 July 2026 | 60% |
| 152 | 25 August 2026 | 80% |
| 154 | 22 September 2026 | 100% |
Rollout schedule per the Chrome team. There’s no Chrome 153 row. Chrome moved to a two-week release cycle in September, so 153 shipped on 8 September with no change to the rollout, and 154 took it to 100% two weeks later.
At the time of writing (mid-August 2026) we’re at the 60% stage, with 80% due on 25 August. So if a user reports “it works on my machine and not on my colleague’s”, both of them are probably right. Explain this to your support team before the 80% milestone, because tickets that only reproduce on some machines are expensive to triage when nobody knows the browser is applying the change gradually.
Why is Chrome doing this at all? The short version is the back/forward cache. A registered unload handler is one of the main things that makes a page ineligible for bfcache, which costs real navigation performance, and the event has been unreliable for years anyway: on mobile especially, the OS kills background tabs without ever firing it. Chrome’s documentation is fairly blunt that unload gave developers a false sense of control. On that point I think they’re right; the replacements below behave better regardless of the policy.
The percentage rollout in the table is Chrome-brand specific; Google drives it through Chrome’s server-side experiment system, and other Chromium-based browsers inherit the deprecation itself but set their own timetables. Microsoft’s message centre notice says Edge started retiring default unload support in early September 2026, with completion expected in October, and the WebView2 announcement says WebView2 applications skip the percentage phasing and switch defaults in one step once the Edge rollout completes, so around October 2026 on Microsoft’s schedule. The ForcePermissionPolicyUnloadDefaultEnabled enterprise policy works across Edge and WebView2 too.
Brave, Opera and Vivaldi haven’t published schedules that we could find; expect the flipped default to reach them as their upstream Chromium base catches up. Firefox and Safari have announced no equivalent change, though unload has long been unreliable in both.
Who’s affected, and who’s fine
If your analytics is GA4 or any mainstream product of similar vintage, you are probably fine. Google’s own guidance moved analytics off unload and onto visibilitychange plus sendBeacon years ago, and the major vendors followed.
The affected population is narrower and mostly consists of code that was written in-house or lives in older dependencies:
- Bespoke save-on-exit code: draft persistence, form state, “resume where you left off” features that flush in an unload handler.
- Custom end-of-session beacons: home-grown analytics, audit trails, “session ended” pings to your own backend.
- Cross-window signalling: opener/popup and controlled child-tab patterns where one window used the other’s
unloadto know it had gone, which is the case we hit ourselves. - Server-side resource release: record locks, seat reservations, collaborative-editing presence, anything where the client told the server “I’m leaving, free my stuff”.
- Session-replay, RUM and older third-party SDKs: some still register
unloadhandlers on your pages, and their breakage is yours as far as your data is concerned. - Test tooling and embedded runtimes: Cypress had to work through the implications for its own use of unload, and libraries like PowerSync hit it in shared-worker cleanup. Next.js users reported the console violation on otherwise unremarkable pages; the culprit there turned out to be a browser extension.
One more group is affected without knowing it: teams whose unload handlers stopped mattering years ago. A surprising amount of unload code is cleanup that the browser does anyway on teardown (clearing timers, removing listeners, closing connections). If that describes yours, the migration is just deleting the handler, which also restores your bfcache eligibility.
How to find your unload usage
Start with a project-wide search in whatever IDE or editor you use (Find in Files in IntelliJ or VS Code, or grep if you prefer the terminal) for these strings, quotes included:
'unload'
"unload"
onunload
.unload(The quote characters are deliberate. They catch nearly every way of registering the handler by name (addEventListener('unload', ...), jQuery’s $(window).on('unload', ...) and .bind('unload', ...), framework wrappers) and the leading quote keeps 'beforeunload' out of the results. jQuery’s space-separated event lists (.on('pagehide unload', ...)) and event names built from variables or template literals will escape it; a follow-up case-insensitive search for the bare word unload mops those up if you want certainty.
onunload covers inline attributes in the markup and window.onunload = assignments. .unload( covers jQuery’s old shortcut method, deprecated in 1.8 and removed in 3.0, though check each match, any object with its own unload() method will also turn up.
Search every file type. The registration often isn’t in a .js file at all: server-rendered applications pick it up from inline scripts in Thymeleaf, JSP, Razor, ERB, Blade or PHP templates, and older pages from onunload attributes in the markup itself. Include your dependency and vendor folders in the search, since a library can register the handler on your behalf.
That finds your own registrations but not what third-party scripts do at runtime, so follow up in the browser. Chrome DevTools has a back/forward cache audit (Application tab, then Back/forward cache) that runs a test navigation and lists unload handlers under actionable issues, including which frame registered them. For measurement at scale, the notRestoredReasons property on PerformanceNavigationTiming reports "unload-listener" as a blocking reason from your real users’ sessions, and the Reporting API can be pointed at a report-only Permissions-Policy to log unload usage across your whole estate before the default flips for everyone.
Don’t skip the third-party pass. In the Next.js thread above, the violation came from a browser extension the developer had installed, and no amount of searching first-party source would have found it. The DevTools audit tells you which frame registered the handler, which is usually enough to work out where the fix needs to go.
The replacement toolbox
Every fix below is assembled from the same handful of pieces. The main source of confusion in this migration is mixing up triggers (events that tell you the page is going away) with transports (mechanisms that move data somewhere before it does), so I’ll keep the two separate throughout.
The triggers
The replacement for the unload trigger is a pair of events used together. pagehide fires when the user navigates away, reloads or closes the tab, and unlike unload it doesn’t disqualify the page from the bfcache. visibilitychange (checking for document.visibilityState === 'hidden') fires earlier and more often: tab switches, minimising, the user going to their home screen on mobile. Chrome’s documentation describes the transition to hidden as the last reliable point to save state, because on mobile the OS can kill a hidden tab without firing anything further, including pagehide.
The standard pattern uses both, with a guard so the work runs once:
let flushed = false;
function flush() {
if (flushed) return;
flushed = true;
// save state / send beacon here
}
window.addEventListener('pagehide', flush);
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') flush();
else flushed = false; // user came back: re-arm
});
// Also re-arm if the page is restored from the bfcache:
window.addEventListener('pageshow', () => { flushed = false; });Note the re-arming. visibilitychange is not a one-shot event like unload was; users switch tabs and come back constantly. Your flush logic needs to tolerate running several times per session, which usually means sending deltas or making the save idempotent. In other words, the save stops being a one-off at session end and runs every time the page stops being visible.
The vanilla version above is all you need whatever your stack; it drops into an inline script in a server-rendered template just as well as into a bundled front end. If your front end is React, the same idea belongs in an effect so the listeners are cleaned up with the component (this version leans on the save being idempotent, since without the once-per-hide guard it can run twice on a close):
useEffect(() => {
const onHide = () => {
if (document.visibilityState === 'hidden') saveDraft();
};
window.addEventListener('pagehide', saveDraft);
document.addEventListener('visibilitychange', onHide);
return () => {
window.removeEventListener('pagehide', saveDraft);
document.removeEventListener('visibilitychange', onHide);
};
}, [saveDraft]);In Next.js this needs to be a client component, and remember that App Router navigations are soft: the page doesn’t unload between routes, so if you were also using unload to catch in-app navigation, that job belongs with your router events or effect cleanups; pagehide won’t see those transitions.
The transports
navigator.sendBeacon(url, data) is the classic teardown transport: a small POST the browser queues and sends even after the page is gone. fetch(url, { method: 'POST', keepalive: true, body }) does the same with the full fetch API (headers, JSON, response handling if the page survives), with a 64KB in-flight quota shared with beacons. Watch the content type, though. A string body goes out as text/plain, so either accept that server-side or wrap the JSON in a Blob with an application/json type. The Blob route is fine same-origin but forces a CORS preflight cross-origin, and beacons handle preflights badly.
Both are best-effort, and the loss rates have been measured, so don’t assume delivery. Volument’s large data study (5.1 million page views) found that around 30% of browsers claiming beacon support failed to deliver beacons sent at page close, with huge variance by platform (their beacons fired from beforeunload, so part of that loss is the trigger’s fault, which is the point the next study makes directly). Speed Kit’s 52-million-page-view benchmark is the more actionable read: beacons sent from unload or beforeunload lost at least 10% of data, while sending from visibilitychange plus pagehide reached about 91% delivery. Most of that difference comes from the choice of trigger.
The newest option closes most of the remaining gap. fetchLater(), which grew out of the PendingBeacon experiments Speed Kit measured at 98% delivery, lets you register a deferred request that the browser itself sends when the page is destroyed, enters the back/forward cache, or a timeout you set expires, no event handler needed. Still about 98% in Speed Kit’s trials, not 100%: a crashed browser or a dead network loses it like anything else. It shipped in Chrome 135 in April 2025. It’s Chromium-only at the time of writing, so I’d treat it as a progressive enhancement layered over a sendBeacon fallback.
if ('fetchLater' in window) {
// Browser sends this automatically at teardown. Note: a pending
// request's body can't be edited; to update the payload, abort it
// (AbortController) and register a new fetchLater().
fetchLater('/api/session-end', {
method: 'POST',
body: JSON.stringify(sessionSummary),
activateAfter: 60 * 60 * 1000 // or on page destruction, whichever first
});
} else {
// visibilitychange/pagehide + sendBeacon fallback as above
}Then there are the transports that don’t involve your server at all. localStorage and IndexedDB writes are the right destination when the state only needs to survive locally (draft recovery on the same machine). window.postMessage() hands data to another window, queued at the moment of the call though delivered asynchronously. And the heavyweight option, a Service Worker with an IndexedDB queue fed by postMessage, gives you retry semantics when a lost beacon is genuinely unacceptable. Each of these turns up in the use-cases below.
Use-case by use-case: the right fix for each job
Find the job your unload handler was doing; the fix is different for each.
Saving state when the user leaves
The draft email, the half-filled form, the scroll position. If the state only needs to exist on this device, write it to localStorage or IndexedDB from the visibilitychange/pagehide pair above, and consider also saving on a debounced input listener so a hard crash loses only a few seconds of work. If the state must reach your server, the same triggers feed sendBeacon or fetch keepalive, with fetchLater() layered on where available. Keep payloads small and idempotent: the handler will fire on every tab switch, and your endpoint has to cope with receiving the same draft several times.
End-of-session analytics and audit pings
If a vendor SDK does this for you, your whole migration is checking the SDK version and reading their changelog. For home-grown beacons, move the trigger to visibilitychange hidden (with pagehide as backstop), accept that “session end” becomes “last time the page was hidden”, and batch state into a summary object you re-send on each hide instead of accumulating a single final payload. That restructuring is what gets you from the 10%-plus loss rates of the unload world to the ~91% the benchmarks measure, and fetchLater() takes Chromium users to roughly 98%.
The controlled close: when your own code closes the tab
This was our case, so it gets the fullest treatment. The pattern: a main window opens a secondary tab for a short-lived task (an approval step, a document edit, an OAuth-style handoff, a payment flow), and the main window needs to know when the task is done. Ours listened for the child tab’s unload, which was always a proxy signal, the thing we actually cared about was “the user finished the task”, and the tab closing just happened alongside it.
The rethink produced better code. When your own script closes the window, you don’t need a lifecycle event at all: you control the exact moment of closing, so you do the work on the line before close():
// In the child tab, when the user completes the action:
function completeAndClose(result) {
// 1. Notify the window that opened us. postMessage queues the
// message on the opener's event loop immediately, so it
// survives the close() below even though delivery itself
// is asynchronous.
window.opener?.postMessage(
{ type: 'task:complete', result },
'https://app.example.com' // always specify the target origin
);
// 2. Anything for the server goes out as a beacon, because a
// normal fetch can be aborted by the close that follows.
navigator.sendBeacon('/api/task-complete', JSON.stringify(result));
// 3. Then, and only then:
window.close();
}And in the opener:
window.addEventListener('message', (event) => {
if (event.origin !== 'https://app.example.com') return;
if (event.data?.type === 'task:complete') {
refreshUI(event.data.result);
}
});Always pass an explicit target origin and check event.origin on receipt; a wildcard is an easy way to leak task results to whatever page ends up in the opener slot. And this only covers the close paths you trigger. The user can still close the tab themselves with the task half-done, so keep a pagehide listener in the child (it fires on tab close, unlike unload now) that posts a task:abandoned message. In practice the opener should also treat “no message and the window handle reports closed” as abandonment, which you can poll cheaply:
const child = window.open(taskUrl);
// window.open() returns null if a popup blocker intervened
const watchdog = setInterval(() => {
if (!child || child.closed) {
clearInterval(watchdog);
handleAbandonedIfNoResultYet();
}
}, 500);The message covers the happy path and the closed poll covers everything else. Neither depends on a teardown event.
Don’t copy this straight into an OAuth or payment flow, though. If the child tab navigates through a page that sends Cross-Origin-Opener-Policy: same-origin (Google sign-in does, as do many payment providers), the browser permanently severs the opener relationship: window.opener becomes null in the child, and the opener’s handle reports closed === true while the tab is still open. Both halves of the pattern misfire. For flows that pass through third-party COOP pages, signal completion from your own same-origin landing page at the end of the flow (a BroadcastChannel, or a fresh postMessage from that page), or poll your server for the completion state.
“Can’t I just use postMessage for everything?”
postMessage worked above because the trigger was the user clicking “done”, an ordinary event you fully control. It’s a transport. It moves data between windows; it can’t tell you the page is going away. If your trigger is “the user is leaving”, you still need pagehide/visibilitychange to fire first, and postMessage is just one place you might send the data from that handler.
Where postMessage does earn a structural role is guaranteed delivery. Get the trigger right first: visibilitychange plus pagehide. Then send with sendBeacon, fetch keepalive or fetchLater; most applications never need more than that. When the benchmarked loss rates are still unacceptable (billing events, compliance audit trails), post the payload to a Service Worker and let the worker own delivery with an IndexedDB-backed retry queue. The worker outlives the page, so a payload that’s crossed the postMessage boundary survives teardown and gets retried on the next visit if the network was down. It needs a registered Service Worker and real engineering effort, so save it for payloads where loss is genuinely unacceptable.
Presence: chat, collaborative editing, “user left”
If your unload handler told the server “I’ve gone” so colleagues stop seeing your cursor, the durable fix is to stop trusting the client to report that it’s gone. It never could, reliably: power cuts, OS tab kills and dropped radios never fired unload either. Make the server authoritative: if the client holds a WebSocket, the server’s close/disconnect handling is the leave signal; supplement with a heartbeat and a TTL so a silent TCP death expires within seconds. A pagehide beacon still helps the common case update instantly; the TTL handles every other exit.
For same-origin multi-tab presence (“is another tab of this app open?”) there’s a useful browser-native option: the Web Locks API. Each tab requests and holds a uniquely-named lock; locks are released automatically when their tab dies, however it dies. Another tab that requests the same lock with a pending callback gets called the moment the holder is gone. Nothing needs to run on the dying page, so it works even when the tab crashed.
Releasing server-side locks and reservations
The classic examples are record locking in a CRM and seat holds in a booking flow. Same principle as presence: send the pagehide beacon so the common case releases the lock immediately, and let a server-side TTL (renewed while the page is visible) handle every other way a client can disappear. A lock that must be explicitly released by a client that may cease to exist is a design bug the unload deprecation is merely exposing. If you have locks today with no expiry, add the expiry before you touch the client code; afterwards, the client-side migration is the standard trigger-plus-beacon pattern.
Multi-tab coordination
Tabs that tell each other about logouts, cache invalidations or “I’m closing, you take over the SharedWorker”. While all parties are alive, BroadcastChannel is the right bus, simpler than the old localStorage-event hack. For detecting that a peer tab has died, don’t have the dying tab announce it; use the Web Locks pattern above, or in SharedWorker setups let the worker track its ports and treat a port that stops responding to pings as gone. PowerSync’s migration (linked earlier) is a real example of moving shared-worker cleanup off unload.
Logging the user out when they close the tab
Some apps used unload to end the server session for security. This was always porous (unload never fired on a crash or OS kill) and the replacement lives on the server: short session TTLs, refresh tokens that expire quickly without activity, and session cookies (as opposed to persistent ones) if “closed the browser” should mean “logged out”. If a regulator or pen-tester asked you to add logout-on-close, they’ll accept idle timeout, which enforces the same property without depending on the browser.
In-page resource cleanup
Handlers that clear intervals, remove listeners, close WebSockets or free WebGL contexts “to be tidy” on unload can very often just be deleted. Document teardown reclaims all of it; the JavaScript heap doesn’t outlive the page. The place this cleanup genuinely matters is in-app: SPA route changes, component unmounts, widget disposal, and none of those ever involved the unload event in the first place (that’s your framework’s cleanup hooks, React’s useEffect return function being one example). Audit each cleanup handler by asking what it protects; if the answer is “memory in a document that’s about to be torn down”, you can delete the handler.
beforeunload is not deprecated
beforeunload, the cancellable event behind the “Leave site? Changes you made may not be saved” prompt, is a different event and is not being switched off. If you use it to warn about unsaved changes, that keeps working.
Chrome no longer blocks bfcache for a registered beforeunload listener (older browsers did, and the advice stuck for good reason), but add it conditionally anyway, only while there are actually unsaved changes, and remove it on save. And don’t use it to save data: on mobile it’s as unreliable as unload was. Keep the saving in the visibilitychange pattern and use beforeunload only for the prompt.
Buying time: the opt-outs
If you’re reading this mid-incident, you can put the old behaviour back today, for your users, without touching handler code.
For your own site, send the header Permissions-Policy: unload=self (or list specific origins; cross-origin iframes additionally need allow="unload" on the frame) and Chrome will allow unload handlers on those pages again. For managed fleets, the enterprise policy ForcePermissionPolicyUnloadDefaultEnabled holds the old default across the estate, which is the pragmatic answer when the breakage is in a vendor app you can’t patch. An earlier origin-trial opt-out, the deprecation trial that ran to Chrome 146, has expired; these two are what remain. There’s also a testing aid that does the opposite: on a developer machine, chrome://flags/#deprecate-unload forces the new behaviour on, so the bug reproduces every time while you test your fix instead of only on some page loads.
Chrome’s stated position is that the opt-out will be supported “for the considerable future”, so there’s no hard cut-off date here. Treat it accordingly: the opt-out is a legitimate way to schedule the migration around your own priorities, and a poor place to stop for good. The replacements also fix reliability problems unload always had, and you don’t get the bfcache benefit until the handlers are gone.
What changed on 22 September
Chrome 154 took the disabled-by-default share to 100%. Nothing was removed, and the opt-outs above keep working. What changed is that the bug stopped being intermittent. Before, it at least got reported as flakiness. Now code paths that depend on unload silently do nothing for every Chrome user who hasn’t been opted out, and you find out weeks later from corrupted data, missing audit rows or locks that never released. Edge users follow once Microsoft’s rollout completes. If you can’t finish the migration yet, ship the Permissions-Policy header now and put the real fix on the backlog with a date.
Add one line to your test strategy as well: make sure your E2E suite runs on Chrome 154 or later, or with the deprecation flag forced on if your CI pins an older browser, since that’s the configuration your Chrome users are now on.
Final thoughts
We’ve focused on Chrome because Chrome is forcing the timetable, but the patterns here are the cross-browser best practice regardless: Firefox and Safari kept unload unreliable in their own ways for years (Safari on iOS often didn’t fire it at all), so code migrated to visibilitychange, pagehide and beacons behaves better in every browser.
The migration comes down to finding every job you’d given to unload and re-homing each one. Local state moves to visibility-triggered saves. Server notifications go over beacons, or fetchLater() where you can use it, or a Service Worker queue where you must. Signals between your own windows become a postMessage at the moment the work completes, as in our controlled-close case, with a closed poll as the safety net. And anything that only worked when the client exited cleanly (presence, locks, logout) is the server’s job now. None of the individual fixes is hard. Most of the effort is the audit itself. The DevTools bfcache check plus a project-wide search is usually enough.
If your team still has a codebase full of unload handlers, whether or not you’ve opted back in for now, this is the sort of modernisation work we do for clients alongside larger builds. Otherwise, we hope the catalogue above saves you some debugging.
