The unload event occurs when the user interups the loading of a page by leaving the page; or when the user clicks on a link, sends a form, closes the browser window or returns to the previous page. In contrast, the "load" event occurs when the page has finished loading.
However, the unload event does not work, especially on cell phones, when :
In addition, the presence of an "unload" event can prevent browsers from caching or placing pages in the background while browsing.
For example : If you are on a web application that plays a video and you decide to view another application at the same time, the unload event can prevent the application containing the video from stopping. The unload will prevent that application from being considered as background, which will not allow the video to be interrupted by switching to another application or web page.
It is recommended on all modern browsers to use the "pagehide" event to detect page unloads.