← Back to release summary

Declarative PendingBeacon API

Category
Network / Connectivity
Type
New or changed feature
Status
No longer pursuing (Chrome No longer pursuing)
Intent stage
Origin Trial

Summary

A JavaScript API to allow website authors to specify one or more beacons that should be sent by the browser when a page is being unloaded. The API improves beaconing when back/forward-cache is used, and it is more reliable than navigator.sendBeacon() or fetch() with keepalive.

Motivation

Web developers have a need for ‘beaconing’ - that is, sending a bundle of data to a backend server, without expecting a particular response, ideally at the ‘end’ of a user’s visit to a page. There are currently four major methods of beaconing used around the web; all suffer from reliability problems, stemming from one core issue: There is not an ideal time in a page’s lifecycle to make the Javascript call to send out the beacon. ‘unload’ and ‘beforeUnload’ are unreliable (and outright ignored by several major browsers), and pageHide and visibilityChanged have issues on mobile platforms. To simplify this issue and make beaconing more reliable, we propose adding a stateful Javascript API where a page can register that it wants a beacon (or beacons) issued when it unloads or the page is hidden. Developers can populate beacon(s) with data as the user uses the page, and the browser ensures beacon(s) are reliably sent at some point in time. This frees developers from worrying about which part of the page lifecycle to send their beacon calls in.

Standards & signals

Ecosystem

Docs: https://github.com/WICG/pending-beacon/blob/main/README.md https://docs.google.com/document/d/1QIFUu6Ne8x0W62RKJSoTtZjSd_bIM2yXZSELxdeuTFo/edit#heading=h.967r92z7a15f

Explainers: https://github.com/WICG/pending-beacon/blob/main/README.md

View on chromestatus.com