0

I'm using navigator.sendBeacon on the front end to tell the server when a user enters and leaves a page (via window.load and window.unload). I'm recording the time of arrival/departure server-side. I'm noticing some instances where there is an arrival time but no departure time.

Are there common circumstances, i.e., not a browser/system crash, under which the window.unload event fails to fire? Perhaps on redirects, back button, or navigation away from a page before all content has loaded?

wrkyle
  • 529
  • 1
  • 13
  • 36

2 Answers2

1

No there is no conditions, outside of browser/system crashes, where the window.unload event will fail to fire. It is supported in all major browsers and many previous versions of all major browsers.

See here as well.

Brian Ogden
  • 18,439
  • 10
  • 97
  • 176
0

Seems like unload event is not fired when a tab is discarded by the chrome memory saver. You can manually navigate to chrome://discards and click on "urgent discard" button, you will see that the tab is labled as unloaded, but the event was not fired.

Check chrome dev blog for more details

nart
  • 1
  • 3