web-vitals
web-vitals: Measure Core Web Vitals in the Browser
Repository Health
Technical Analysis
web-vitals is a tiny (~2KB brotli’d), modular library from the Chrome team for measuring the Core Web Vitals — Cumulative Layout Shift (CLS), Interaction to Next Paint (INP), and Largest Contentful Paint (LCP) — plus supporting metrics like First Contentful Paint (FCP) and Time to First Byte (TTFB), on real users in production. Crucially, it calculates each metric the exact same way Chrome does internally, so the numbers match what shows up in the Chrome User Experience Report, PageSpeed Insights, and Search Console’s Speed Report.
Each metric is exposed as a single function (onCLS, onINP, onLCP, onFCP, onTTFB) that takes a callback fired once the value is ready to report, with support for reporting on every change, reporting only deltas, and batching multiple metric reports together before sending them to an analytics endpoint. An optional “attribution” build adds diagnostic detail (e.g. which DOM element caused the layout shift) to help pinpoint the root cause of a poor score.
What You Get
onCLS,onINP,onLCP,onFCP,onTTFB- one function per metric, each accepting a callback fired when the value is ready to report- A “standard” build (~2KB) and an “attribution” build (+1.5KB) that adds root-cause diagnostic data to each metric
reportAllChangesoption to observe a metric’s value as it changes in real time, useful for debugging- Delta-based reporting via each metric’s
id/deltafields, for analytics providers that can’t overwrite previously-sent values - Built-in handling of edge cases: back/forward cache restores, page visibility changes, and pages loaded in the background
Common Use Cases
- Sending real-user Core Web Vitals data to Google Analytics or Google Tag Manager to track site performance over time
- Piping metrics to a custom analytics/RUM backend via
navigator.sendBeaconorfetchfor internal performance dashboards - Debugging a specific poor Core Web Vitals score using the attribution build to identify the exact element or resource responsible
- Correlating field (real-user) performance data against lab-based Lighthouse scores to validate synthetic testing results
Under The Hood
Architecture Each metric has a dedicated entry file (src/onCLS.ts, src/onINP.ts, src/onLCP.ts, src/onFCP.ts, src/onTTFB.ts) that wires a PerformanceObserver (via the shared src/lib/observe.ts helper) to metric-specific accumulation logic — e.g. LayoutShiftManager.ts sums layout-shift session windows for CLS, InteractionManager.ts and LCPEntryManager.ts track interaction/paint timing for INP and LCP — then reports through a shared bindReporter.ts callback wrapper that handles the report-once vs report-all-changes vs delta-reporting behavior uniformly across metrics. Tech Stack Modular TypeScript (36% of source) compiled to ESM/CJS/IIFE bundles via Rollup, published with an exports map allowing consumers to import individual metric functions (tree-shakeable) or the full web-vitals or web-vitals/attribution entry points; there are no runtime dependencies. Code Quality The test/ directory pairs unit tests with WebdriverIO-driven browser integration tests (wdio.conf.js) that exercise real Core Web Vitals behavior across actual browser sessions rather than mocked APIs, reflecting the project’s status as the reference implementation Chrome itself validates other tools against; ESLint (flat config) enforces consistent style. API Design The one-function-per-metric design (onCLS(callback), onLCP(callback), etc.) is deliberately minimal — a single import and callback gets a working integration, and the standard vs attribution build split lets consumers opt into diagnostic complexity only when they need root-cause data, keeping the default path lightweight.
Used by 26 apps in this directory
APITable
Low Code Platforms · Databases
API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.
Amplication
Developer Tools · AI Code Assistants · Automation
Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.
Anarlog
Note Taking · AI Assistants · Productivity
Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.
Appsmith
Developer Tools · Automation · No Code Platforms
Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.
Cosmos-Server
Security · Authentication
All-in-one self-hosted home server with SmartShield anti-DDoS, Nebula mesh VPN, automatic HTTPS, and a 250-app marketplace — all secured behind a unified auth layer.
GitLab
Devops · Developer Tools
The complete DevOps platform that unifies Git hosting, CI/CD, issue tracking, and security scanning into a single self-hostable application.
highlight.io
Developer Tools · Analytics · Monitoring
Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.
Langflow
AI Agents · AI Development
Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.
Laudspeaker
Marketing · Automation
Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.