Use fetch keepalive instead of sendBeacon
javascriptbrowser
One of the fetch
API options is keepalive
. This has the same behaviour as sendBeacon API to send analytics or simply calls to the server you don't want to be aborted when navigating though pages.
The reason to prefer keepalive: true
instead of sendBeacon
is that adBlocks seems to be blocking sendBeacon requests.
I learnt this from @stefanjudis