Using the Beacon API

Using the Beacon API

Users are so annoying! There they go, leaving the page before we can save the data to the API. Back in the old days, we would attach a `window.unload` handler and try to send an AJAX request, but this was slow and unreliable.

Enter the Beacon API to give us a better way.

The Beacon provides a reliable way to send a small amount of data *after* the page has been unloaded. It's not bound to the lifetime of the page and it doesn't slow down the user.

Read more at https://requestmetrics.com/making-of/using-the-beacon-api