-
Notifications
You must be signed in to change notification settings - Fork 237
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
[BUG] Violation of Lighthouse Best Practice — 'Registers an unload listener' #1620
Comments
We register and listen to "unload", "beforeunload", "pagehide" and "visibilitychange" (this last one as of last release). We need to listen to all possible events to support the full browser matrix and not just more modern browser that support the other events. As such we NEED to continue listening to the unload event so that we can flush any unsent event in ALL browsers. |
Interesting argument. We also load Google Analytics and Google Analytics 4. No violations there. |
Their supported browser matrix is a lot smaller than ours https://support.google.com/analytics/answer/3541880?hl=en |
@MSNev that refers to browsers one can use to access the analytics dashboard. Of course the script itself will work on all versions of all browsers.
This sounds like an expensive way to do things. Should be based on feature detection. |
We effectively are performing a lightweight form of feature detection if the event is available we hook it, otherwise we don't. So this is the entire attach code required and and it's effectively called this 4 times this also attempts to list to the event at the window, body and document level, again this is to support all of the legacy browsers and platforms as not all support the events at the window level Some of this is more complex than we would like, but it is required as we are providing support for IE 8+ with active end-user customers still actively using IE8 (and in some cases IE7 😥 ). |
FYI - We have now supplied an optional configuration settings to allow you to "request" that you don't want the "unload" event to be hooked #1683. The reason for calling it a "request", is that if the runtime environment fails to hook any "unload" event (taking the excluded set into account), then it will still hook the default set of events. |
This will be release in the next release which is currently planned to be v2.7.1 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description/Screenshot
Steps to Reproduce
Expected behavior
No violation
Additional context
Clicking on 'Learn More' takes you to this page: https://developers.google.com/web/updates/2018/07/page-lifecycle-api?utm_source=lighthouse&utm_medium=devtools#the-unload-event
The text was updated successfully, but these errors were encountered: