Skip to content

Commit

Permalink
Report all web vital metric changes (#949)
Browse files Browse the repository at this point in the history
With this change, the Web Vital callbacks will be called for all
changes. instead of waiting for them to complete.

See this comment:
If the `reportAllChanges` configuration option is set to `true`, the
`callback` function will be called as soon as the value is initially
determined as well as any time the value changes throughout the page
lifespan.

https://github.com/GoogleChrome/web-vitals/blob/5973d51be39ab0020268aa2397ead0962eedf4c2/src/onCLS.ts#L43-L46
  • Loading branch information
inancgumus authored Jun 23, 2023
1 parent 9965947 commit f25b1d4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions common/js/web_vital_init.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ function print(metric) {
}

function load() {
webVitals.onCLS(print);
webVitals.onFID(print);
webVitals.onLCP(print);

webVitals.onFCP(print);
webVitals.onINP(print);
webVitals.onTTFB(print);
const reportAllChanges = {
reportAllChanges: true,
}
webVitals.onCLS(print, reportAllChanges);
webVitals.onFID(print, reportAllChanges);
webVitals.onLCP(print, reportAllChanges);
webVitals.onFCP(print, reportAllChanges);
webVitals.onINP(print, reportAllChanges);
webVitals.onTTFB(print, reportAllChanges);
}

load();

0 comments on commit f25b1d4

Please sign in to comment.