News for hackers. Stuff that matters.
Re:Deprecating the `Unload` Event by paulddraper on Thursday August 10, 2023 @04:16PM (#37081185)
1. Does the WhatWG standard matter anymore?

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

Re:Deprecating the `Unload` Event by lioeters on Thursday August 10, 2023 @04:37PM (#37081445)
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.

Re:Deprecating the `Unload` Event by yMMe2WYE_D on Friday August 11, 2023 @05:03AM (#37086597)
> 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.

Re:Deprecating the `Unload` Event by matthews2 on Thursday August 10, 2023 @05:00PM (#37081716)
WhatWG is more like documentation of what browsers are currently doing, rather than a standard
Re:Deprecating the `Unload` Event by paulddraper on Thursday August 10, 2023 @05:37PM (#37082116)
Okay so this is an announcement WhatWG will change :)
Re:Deprecating the `Unload` Event by lapcat on Thursday August 10, 2023 @07:44PM (#37083184)
Note that Safari deprecated "unload" a long time ago: https://developer.apple.com/library/archive/documentation/Ap...