Shahin

pagehide Event

Advanced
Updated Jul 11, 2026 Shahin editorial 2 min read
PronunciationEN/ˈpeɪdʒhaɪd ɪˈvɛnt/

The pagehide event is the moment the browser signals that the page is being hidden or left; the last reliable chance to send any data collected up to that point.

The challenge of data collection is that some things only make sense at the end of a visit — time spent on the page, final scroll depth, or events still queued to send — and must go out just before the user leaves. The pagehide event exists for this, and today it is a more reliable replacement for the old unload event, which was unreliable on mobile. But there is a subtlety: the user may close the page or merely switch to another tab and come back, so precise tools read pagehide alongside the visibilitychange event to cover both a real end and a temporary hide. Because time is short at this moment, the data must be sent by a method that neither slows the departure nor gets canceled.