Search code examples
javascripthtmlnavigatoronunloadsendbeacon

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


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?


Solution

  • 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.