ampproject / ampproject/amphtml
Use @google-chrome/web-vitals for CWV measurements
- Dominant language
- JavaScript
- Stars
- 14.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
### Description
We currently have a bunch of custom code within `src/performance-impl.js` to calculate CWV values.
There are a couple of compelling reasons I believe it may be worthwhile to switch to using the [web-vitals](https://github.com/GoogleChrome/web-vitals) package.
- Maintenance burden: vitals are going to keep changing. For example the new normalized CLS metric
- Correctness: We've had many bugs in our metric collection. In fact, we still do have a few that Philip Walton found (on top of this latest load/render fiasco)
**caveats**
- We need to measure impact on bundle size
- We have an additional "backgrounding" event that the package doesn't know about which may be relevant for CLS (viewer backgrounding).
### Additional Context
Fixes https://github.com/ampproject/amphtml/issues/33326
Contributor guide
Research direction
Start with src/performance-impl.js and compare the existing CWV measurement flow with the @google-chrome/web-vitals package. Check the bundle-size impact and account for the additional viewer-backgrounding event relevant to CLS. Done means the custom measurement code is replaced without losing that behavior or correctness.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100