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

Unsubscribe on beforeunload instead on unload has Chrome will stop firing unload events #285

Open
SuperPat45 opened this issue May 11, 2023 · 1 comment

Comments

@SuperPat45
Copy link
Contributor

SuperPat45 commented May 11, 2023

The unload event is used to unsubscribe the connection.

Chrome lighthouse audit say the unload event is a bad practice and prevent Back/forward cache

A browser optimization that enables instant back and forward navigation. It significantly improves the browsing experience for users—especially those with slower networks or devices.

Would it not be better to unsubscribe on beforenuload event instead?
beforenuload still prevent back/forward cache on Firefox, but not on Chrome.
I don't know if there would be any other implications.

@SuperPat45
Copy link
Contributor Author

SuperPat45 commented Aug 15, 2023

According to this article: https://developer.chrome.com/blog/deprecating-unload/

The unload event will be gradually deprecated starting from Chrome 117. The deprecation will occur by gradually changing the default so that unload handlers stop firing on pages unless a page explicitly opts in to re-enable them.

@SuperPat45 SuperPat45 changed the title Unsubscribe on beforeunload instead on unload fore Back/forward cache compatibility Unsubscribe on beforeunload instead on unload has Chrome will stop firing unload events Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant