Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 3 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

Web Vitals

Measure Core Web Vitals and other key performance metrics in JavaScript.

Logging, monitoring and analyticsNPM

GitHubWebsite

1. License

License from npm.

github.com/GoogleChrome/web-vitals

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What Web Vitals does

web-vitals is Google Chrome's own field-measurement library: it reports CLS, INP and LCP from real users in a way the README says "accurately matches" how Chrome measures them and reports them to Google tools, and you can load it late without losing data.

Web Vitals popularity

76 / 100
Gid Score, #172 overall
92.1M
downloads a week, npm
8,700
GitHub stars
47
agent projects use it
Web Vitals: downloads per weeknpm, web-vitals 92,054,080
Web Vitals: GitHub starsGoogleChrome/web-vitals 8,700

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How Web Vitals is used

  • Web Vitals is a dependency in 47 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (1.0% of the 4,867 JavaScript/TypeScript ones), #15 of 121 in logging, monitoring and analytics.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 311; those are left out of every share on this page.
  • The most used alternative in our scan is Vercel Speed Insights (109 projects).
  • Projects that use it most often also use Testing Library (85.1%), React (89.4%), Vite (66.0%).

By coding agent

26 projects, 1.1%
26 projects, 0.8%
19 projects, 0.6%
6 projects, 2.2%
5 projects, 1.1%

Often used with

In 85.1% of its projects
In 89.4% of its projects
In 66.0% of its projects
In 59.6% of its projects
In 48.9% of its projects
In 42.6% of its projects
In 55.3% of its projects
In 34.0% of its projects

Web Vitals in practice

Strengths

Numbers line up with Google's own tools

The README says the library measures each metric the way Chrome does and the way it is reported to CrUX, PageSpeed Insights and Search Console's Speed Report.

Can be loaded late without missing data

The library uses the <code>buffered</code> flag on <code>PerformanceObserver</code>, so it still sees performance entries from before it loaded. The README recommends deferring it until other user-impacting code has loaded.

An attribution build that explains bad scores

Change the import to <code>web-vitals/attribution</code> and each metric object gets an extra <code>attribution</code> property with diagnostic details. The README says this build is about 1.5K (brotli'd) larger and recommends it only if you use those features.

Deltas for analytics backends that can't overwrite

Each report carries an <code>id</code> and a <code>delta</code>. If your analytics provider cannot update a value it has already received, you send deltas and sum them by ID.

Watch out for

Some values arrive late

Some metrics wait until the user interacts, switches tabs, or the page starts to unload. CLS and INP are reported again when the page becomes hidden. All metrics are reported again after a back/forward cache restore.

Some callbacks never fire

INP is missing if the user never interacts with the page. CLS, FCP and LCP are missing if the page loaded in the background. Expect gaps in your data.

Call each function once per page

Each <code>on*</code> call creates a <code>PerformanceObserver</code> and listeners that stay for the life of the page. The README warns that repeated calls can increase memory overhead.

Report only the delta of each change

import {onCLS, onINP, onLCP} from 'web-vitals';

function logDelta({name, id, delta}) {
  console.log(`${name} matching ID ${id} changed by ${delta}`);
}

onCLS(logDelta);
onINP(logDelta);
onLCP(logDelta);

More about Web Vitals

Packages around it
  • @testing-library: Component testing
  • react-scripts: Create React App tooling
  • react: UI library
  • react-router-dom: Client-side routing
  • @emotion: CSS-in-JS styling
  • axios: HTTP client
More in Logging, monitoring and analytics

Alternatives

Web Vitals This page

Apache-2.0Gid 7692.1M/wk

Vercel Speed Insights

Measure web performance metrics and get recommendations for improvement.

Apache-2.0Gid 557.3M/wk

Compare Web Vitals with another tool

Get started

Install it.

npm install web-vitals

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## Web Vitals
- Install with `npm install web-vitals` and import from the package. The README calls npm the recommended way. If you must use a script tag, self-host the built files rather than relying on unpkg, jsDelivr or cdnjs.
- Defer loading the library until after other user-impacting code. The `buffered` flag means early entries are not lost.
- Call each of `onCLS()`, `onINP()`, `onLCP()` once per page load. Repeated calls add `PerformanceObserver` instances and listeners for the life of the page.
- Import from `web-vitals/attribution` only when the code actually reads the `attribution` property. It adds about 1.5K brotli'd.
- For analytics backends that cannot overwrite a sent value, send `delta` and group by `id`. A back/forward cache restore produces a new `id`.
- Do not enable `reportAllChanges` in production. The README says it is for debugging.
- Do not assume callbacks fire immediately, or at all. With `reportSoftNavs`, use the `navigationURL` property instead of the current URL.