Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark unload as deprecated #21480

Merged
merged 4 commits into from
Dec 14, 2023
Merged

Conversation

tunetheweb
Copy link
Contributor

Summary

The unload event is unreliable on mobile (all browsers) and desktop (safari) where it only fires ~60% of the time.

Chrome has stated it's intent to deprecate it: https://developer.chrome.com/docs/web-platform/deprecating-unload and it was previously proposed to mark it as not supported in #20597 - which was correctly closed as too early, and instead a documentation issue was raised to discuss this: mdn/mdn#462.

This PR proposes leaving the support as is (with a note for Chrome), but marking it as deprecated to warn developers more that it should not be relied on.

It should be noted that Safari and Firefox are not quite on board with the path to get there:

However, the MDN documentation page has had a warning at the top of it's page for as long as that repo existed (3 years):
https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event

image

So, given it is unrealiable on mobile for all browsers and desktop Safari, that Chrome intends to deprecate it fully, and that we have had a warning at the top of the documentation page for a long time, it seems to me it fits the MDN definition of deprecated:

The term deprecated on MDN Web Docs is used to mark an API or technology that is no longer recommended. A deprecated API or technology might be removed in the future or might only be kept for compatibility purposes and may still work. We recommend to avoid using the functionality marked as deprecated.

It has not yet been formally deprecated in the HMTL spec, which might be more problematic for the BCD definition of deprecated which prefers an actual specification update or at least a position.

Discussions in the spec have been ongoing for a while:
whatwg/html#6026

The spec has clarified that the unload handler does not need to run any more when the bfcache can be used - in effect codifying the mobile and Safari unreliability.

TLDR: it's messy but this event really is not recommended to be used (as shown by the warning on MDN already) and that is only likely to increase.

Test results and supporting details

See above

Related issues

Issue to document this deprecation journey: mdn/mdn#462

@github-actions github-actions bot added data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API data:svg Compat data for SVG features. https://developer.mozilla.org/docs/Web/SVG labels Dec 5, 2023
Copy link
Contributor

@queengooborg queengooborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM!

@queengooborg queengooborg merged commit 35a3654 into mdn:main Dec 14, 2023
@tunetheweb tunetheweb deleted the mark-unload-as-deprecated branch December 18, 2023 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API data:svg Compat data for SVG features. https://developer.mozilla.org/docs/Web/SVG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants