-
Notifications
You must be signed in to change notification settings - Fork 426
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
Refactor the stopListening()
function to only run once
#548
Conversation
Could you explain what the "subtle logic difference" is and why that means it could run more that once? And won't the |
With the current logic, the With my changes, the
Yes, I think it will. I'd actually forgotten about that, so maybe the |
It looks like the |
Cool. I figured it was the three click handlers, but with the guard I wasn't 100% sure. Personally I have the |
I decided to remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
However, I don't think this was really an issue. Click and Keyboard will prevent the browser from emitting a new LCP anyway so there shouldn't in theory be later LCP entries after those.
See: https://resource-loading.glitch.me/slow-lcp.html
But let's clean it up anyway!
This PR fixes a subtle logic difference introduced in #538.
Previously, the
stopListening()
function inonLCP.ts
would only ever run once, but with the change in #538 it could run more than once. I don't think this would result in any real change in behavior (since the metric shouldn't have changed between invocations); however, I think it's still better to restore the previous behavior.