navigator.sendBeacon()
A browser function that queues a small POST request to be sent reliably even while the page is unloading.
In more detail
The browser sends the data in the background and the page cannot read any response. It was built for analytics on exit but only supports POST and no custom headers; fetch with keepalive covers the same need more flexibly.
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.
- page unload — The moment a page is being closed or navigated away from, when ordinary requests may be cancelled.
- telemetry — The data a running system sends out about itself, such as logs, metrics and traces.
Taught in
- The Fetch API: Streaming Responses, HTTP Caching And Keepalive — Frontend Architecture & Web Platform