Are there any conditions under which window.unload event does not fire?

639 Views Asked by At

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?

2

There are 2 best solutions below

0
On BEST ANSWER

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.

0
On

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