Skip to content

Commit

Permalink
Fix memory leak in registering new event listeners on ever keydown an…
Browse files Browse the repository at this point in the history
…d click (#554)
  • Loading branch information
tunetheweb authored Oct 22, 2024
1 parent a4ab006 commit 752610a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/onLCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export const onLCP = (
// Wrap in a setTimeout so the callback is run in a separate task
// to avoid extending the keyboard/click handler to reduce INP impact
// https://github.com/GoogleChrome/web-vitals/issues/383
addEventListener(type, () => whenIdle(stopListening), true);
addEventListener(type, () => whenIdle(stopListening), {
once: true,
capture: true,
});
});

onHidden(stopListening);
Expand Down

0 comments on commit 752610a

Please sign in to comment.