page unload
The moment a page is being closed or navigated away from, when ordinary requests may be cancelled.
In more detail
On mobile, pages are often discarded without any unload event firing at all. Send final analytics on visibilitychange or pagehide rather than unload, which is unreliable, using fetch keepalive or sendBeacon.
Related terms
- fetch keepalive — A fetch option, keepalive: true, that lets a small request keep going after the page that started it has been closed or navigated away.
- navigator.sendBeacon() — A browser function that queues a small POST request to be sent reliably even while the page is unloading.
Taught in
- The Fetch API: Streaming Responses, HTTP Caching And Keepalive — Frontend Architecture & Web Platform