ampproject / ampproject/amphtml

Use @google-chrome/web-vitals for CWV measurements

Open
#36,145 1 comment 0 reactions 0 assignees View on GitHub
Stale Type: Feature Request
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.