From the course: Vanilla JavaScript: Web Performance Optimization APIs

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Send low-priority requests with beacons

Send low-priority requests with beacons - JavaScript Tutorial

From the course: Vanilla JavaScript: Web Performance Optimization APIs

Start my 1-month free trial

Send low-priority requests with beacons

- [Instructor] It's time to see some modern APIs available in vanilla JavaScript to execute our code more efficiently. We're going to start talking about the Beacon API; that has nothing to do with Bluetooth beacons. So, this is useful for analytics, trackers, or state updates that you are currently sending over AJAX or typical fetch requests. We are going to use this API when waiting for a response is not really important. For example, let's say the user is clicking a link and we want to save stats and analytics server-side to know how many clicks that link has received. So, we don't want to wait for a response, it's just, okay, server, the user has just clicked here. I don't care about a response. Also, those requests shouldn't be high-priority, so I don't want to mess with the performance of my app because I'm sending that track information. Also, what happens if the user doesn't have connection at that time, or if the user is closing the browser or the tab, or if the user is going…

Contents