What is the navigator.sendBeacon() API, and how is it used in HTML?

sendBeacon allows sending data to a server asynchronously, especially suited for logging and analytics, without blocking page unload events.

Example:

navigator.sendBeacon('/log', JSON.stringify({event: 'page_unload'}));