I am trying to figure out how the unload event works. I use the $(window).unload() handler to send a list of several user values โโto my analytic service when the user goes to another page. I am making a separate API call for the service for each value.
I'm just wondering if I can count on my handler to work every time until it finishes, or if there will be times when loading the next page will interrupt it before it can register all the values โโin the list.
The jQuery documentation for .unload () reads: "Cannot cancel unload event with .preventDefault ()." For me, this means that after the browser starts executing your upload handler, there is no way to keep it from loading, parsing, and executing JS of a new page.
But the MDN page in the window.onunload event says: "Removing resources is processed after the unload event occurs."
Does this mean that the browser runs the page upload function before it is completed, and only then removes it to load the next JS page?
source share