sendBeacon allows sending data to a server asynchronously, especially suited for logging and analytics, without blocking page unload events.
sendBeacon
Example:
navigator.sendBeacon('/log', JSON.stringify({event: 'page_unload'}));