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
  • Loading branch information
tunetheweb committed Oct 22, 2024
1 parent a4ab006 commit 0b2f37e
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 0b2f37e

Please sign in to comment.