Skip to Content
Platform.Ontology

pagehide, visibilitychange and unload

Events that tell a page it is being hidden, left or closed so it can save state or send a last report.

Works without askingTracking across apps and sitesAfter leavingWeb browsersAfter you leave the site

In one line

Can tell a page when you hide or leave it, so it can send a report

Events that tell a page it is being hidden, left or closed so it can save state or send a last report.

visibilitychange and pagehide are the reliable last chance for a final send. unload is being retired: Chrome is deprecating it with a Permissions-Policy and completing the change in late 2026. beforeunload is unreliable on mobile.

What it can and can't do

What the user does: You switch tabs, close the tab or leave the page

It can

  • Know when you hide or leave a page
  • Save your progress or settings
  • Send a final report, such as time spent, through other tools

It cannot

  • Always run, since phones and Chrome may skip the unload event
  • Stop you from leaving
  • Keep the page running after it closes
  • See what you do on the next page

How it differs between platforms: Chrome and Edge limit the unload event. Safari and Firefox run it more often.

Browser support

BrowserStatusFirst versionReleasedNote
ChromePartial32009-09-15unload is being phased out in Chrome 154 to 155
EdgePartial122015-07-29None
FirefoxSupported62011-08-16None
SafariSupported52010-06-07None
Safari on iPhoneSupported4.22010-11-22None
Chrome on AndroidPartial182012-06-27None
Samsung InternetSupported1.02013-04-27None

How a site asks for it

APIdocument.visibilitychange, window.pagehide, beforeunload, unload
Permissions policyunload
Browser compat keysapi.Window.pagehide_event
api.Document.visibilitychange_event
api.Window.unload_event
How access is grantednone
What the user seesNone
Needs a secure context (HTTPS)No
Needs a user gestureNo
How long it lastsFires once at exit or tab hide
How to take it backClear site data, browser privacy settings
Inside an iframeNot listed

Data you get

What comes back: Lifecycle events
Shape: event
How often: once at exit

No individual data fields. The signal is the access itself.

Technical limits

  • unload does not fire reliably on mobile or in bfcache
  • beforeunload prompt requires a user gesture on the page
  • Chrome deprecation of unload completes about Chrome 154 to 155 (Sep to Oct 2026)
  • Only about 100s of ms of work is safe

The story

What it is

Events that tell a page it is being hidden or closed, so it can save and send a last report.

For you

You never see it. When you switch tabs or close the page, the page gets a short warning. It uses that moment to save your work or send a last report. Old unload events are being retired.

For makers

Pages die with little notice, especially on phones. Hidden and pagehide are the reliable last chance to send data. Games and editors use them to save progress, and analytics use them to finish counting time on page.

Where you see it

TypeExampleApps
productivityAn online editor saves your draft the moment you switch tabs, so nothing is lost if the browser crashes.Google Docs, Notion
gamesA browser game pauses and saves your state when you switch tabs, and sends progress to the server.Slither.io, Krunker
videoA video site sends your watch position when you leave, so you can resume later.YouTube, Netflix
analyticsAn analytics script sends your time on page when the tab becomes hidden.Google Analytics
liveA live stream pauses the video feed to save data when you hide the tab, and resumes when you return.Twitch
adsAn ad tag stops counting visible time when the page goes into the background.Google Ad Manager

Risks

  • Sends data at a moment you cannot stop
  • Old unload events are fading

What the platform says

Good uses and abuse

Legitimate uses

  • Saving drafts, session end events

Known abuse

  • Last gasp tracking

Scores

ScoreValueMeaning
Sensitivity2 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bitsNot ratedRough identifying entropy, when known

History

  • 2023-07, Chrome 115: Permissions-Policy: unload introduced
  • 2024-01, Chrome 117: Gradual unload deprecation rollout began
  • 2026-09, Chrome 154: Deprecation completes by default (Sep to Oct 2026 per Chrome plan)
  • navigator.sendBeacon. Can send a small report that the browser delivers even as you leave the page
  • Back forward cache. Can freeze this page when you leave and bring it back instantly on Back

Sources

How well checked: Checked against real behavior.

On this page