We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1509d64 commit e22d23bCopy full SHA for e22d23b
src/lib/whenIdleOrHidden.ts
@@ -29,7 +29,12 @@ export const whenIdleOrHidden = (cb: () => void) => {
29
cb();
30
} else {
31
cb = runOnce(cb);
32
- rIC(cb);
33
document.addEventListener('visibilitychange', cb, {once: true});
+ rIC(() => {
34
+ cb();
35
+ // Remove the above event listener since no longer required.
36
+ // See: https://github.com/GoogleChrome/web-vitals/issues/622
37
+ document.removeEventListener('visibilitychange', cb);
38
+ });
39
}
40
};
0 commit comments