6 comments

[ 3.6 ms ] story [ 21.9 ms ] thread
1. Does the WhatWG standard matter anymore?

2. No mention of beforeunload. I imagine that is still good?

According to the Chrome Developers page on the Page Lifecycle API [1], and the MDN page [2], it seems `beforeunload` is still OK to use.

https://developer.chrome.com/blog/page-lifecycle-api/#event-...

https://developer.mozilla.org/en-US/docs/Web/API/Window/befo...

Both sites emphasize that it should be used only minimally, to attach and remove an event listener as needed, i.e., when there are unsaved changes.

---

> ..On Firefox, the beforeunload event is not compatible with the back/forward cache (bfcache): that is, Firefox will not place pages in the bfcache if they have `beforeunload` listeners, and this is bad for performance.

> However, unlike the `unload` event, there is a legitimate use case for the `beforeunload` event: the scenario where the user has entered unsaved data that will be lost if the page is unloaded.

> It is recommended that developers listen for `beforeunload` only in this scenario, and only when they actually have unsaved changes, so as to minimize the effect on performance.

> should be used only minimally

Like that will ever happen. I just got such warning while leaving https://news.ycombinator.com/item?id=37086041 , probably some ad on Forbes site used it. It is like with right mouse click menu - the only sites that really need to replace it is Google Docs or equivalent, yet there are thousands of sites that restrict it for "security" or some other crazy reason.

WhatWG is more like documentation of what browsers are currently doing, rather than a standard
Okay so this is an announcement WhatWG will change :)