Skip to content

Commit 752610a

Browse files
authored
Fix memory leak in registering new event listeners on ever keydown and click (#554)
1 parent a4ab006 commit 752610a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/onLCP.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ export const onLCP = (
104104
// Wrap in a setTimeout so the callback is run in a separate task
105105
// to avoid extending the keyboard/click handler to reduce INP impact
106106
// https://github.com/GoogleChrome/web-vitals/issues/383
107-
addEventListener(type, () => whenIdle(stopListening), true);
107+
addEventListener(type, () => whenIdle(stopListening), {
108+
once: true,
109+
capture: true,
110+
});
108111
});
109112

110113
onHidden(stopListening);

0 commit comments

Comments
 (0)