web-vitals : The web-vitals JavaScript is a tiny, modular library for measuring all the web vitals metrics on real users.
This technology is used by 0.93% of websites in the JavaScript libraries category. The most popular industry vertical is Style & Fashion, with Arts and Crafts being the top subcategory.
What is Web Vitals?
Web Vitals is a Google initiative and JavaScript library for measuring real user experience metrics on websites. The library provides tools to capture Core Web Vitals and other performance metrics that indicate page quality. These metrics help developers understand how users actually experience their websites beyond synthetic testing.
Core Web Vitals include Largest Contentful Paint (LCP) measuring loading performance, Interaction to Next Paint (INP) measuring interactivity, and Cumulative Layout Shift (CLS) measuring visual stability. These three metrics form the foundation of Google's page experience signals used in search ranking.
The web-vitals JavaScript library enables easy measurement of these metrics directly in production. The library uses browser Performance APIs to capture accurate timing data from real user sessions. This real user monitoring (RUM) provides insights that lab testing alone cannot capture.
Beyond Core Web Vitals, the library measures additional metrics like First Contentful Paint (FCP), First Input Delay (FID), and Time to First Byte (TTFB). These supplementary metrics provide deeper insight into specific aspects of page performance.
Detection of web-vitals on a website indicates commitment to performance monitoring and user experience optimization. Development teams using web-vitals typically prioritize page speed, monitor production performance, and optimize based on real user data.
Industry Vertical Distribution
Technologies Frequently Used with web-vitals
| Technology | Co-usage Rate | Website |
|---|---|---|
| HSTS | 79.48% | https://www.rfc-editor.org/rfc/rfc6797#section-6.1 |
| HTTP/3 | 75.34% | https://httpwg.org/ |
| Open Graph | 71.16% | https://ogp.me |
| core-js | 59.57% | https://github.com/zloirock/core-js |
| Boomerang | 51.58% | https://akamai.github.io/boomerang |
| Module Federation | 51.11% | https://webpack.js.org/concepts/module-federation/ |
| Facebook Pixel | 51.01% | http://facebook.com |
| webpack | 49.37% | https://webpack.js.org/ |
| 37.52% | http://facebook.com | |
| PayPal | 36.54% | https://paypal.com |
Web Vitals Library Features
Core Web Vitals: LCP measurement for loading. INP measurement for interactivity. CLS measurement for stability. Google-defined thresholds.
Additional Metrics: FCP for first content render. FID for first interaction. TTFB for server response. Complete performance picture.
Real User Data: Production measurement. Actual user experiences. Device and network variety. Geographic distribution.
Attribution Data: Identify performance causes. Element-level attribution. Debug information included. Root cause analysis.
Lightweight: Small bundle size. No dependencies. Minimal performance impact. Efficient implementation.
Browser Support: Modern browser APIs utilized. Graceful degradation. Cross-browser compatibility. Feature detection built-in.
Easy Integration: Simple API surface. Callback-based results. Analytics integration ready. Flexible reporting options.
AI-Powered Technology Recommendations
Our AI recommender engine, trained on 100 million data points, suggests these technologies for websites using web-vitals:
| Technology | AI Score | Website |
|---|---|---|
| HSTS | 0.63 | https://www.rfc-editor.org/rfc/rfc6797#section-6.1 |
| HTTP/3 | 0.39 | https://httpwg.org/ |
| Facebook Pixel | 0.22 | http://facebook.com |
| Boomerang | 0.2 | https://akamai.github.io/boomerang |
| Module Federation | 0.16 | https://webpack.js.org/concepts/module-federation/ |
| Mediavine | 0.14 | https://www.mediavine.com |
| Ezoic | 0.14 | https://www.ezoic.com |
| Apple Pay | 0.14 | https://www.apple.com/apple-pay |
| Shop Pay | 0.1 | https://pay.google.com |
| Pinterest Ads | 0.1 | https://ads.pinterest.com/ |
IAB Tier 1 Vertical Distribution
Relative Usage by Industry
Market Distribution Comparison
Web Vitals Use Cases
Performance Monitoring: Track real user performance. Monitor production metrics. Identify degradation. Measure improvements.
SEO Optimization: Core Web Vitals affect rankings. Page experience signals. Search performance improvement. Competitive advantage.
User Experience Analysis: Understand actual user experience. Identify slow experiences. Segment by device type. Geographic analysis.
Performance Budgets: Set metric thresholds. Alert on violations. Maintain performance standards. Prevent regressions.
A/B Testing: Measure performance impact of changes. Compare variant performance. Data-driven decisions. Performance validation.
Development Workflow: Pre-deployment testing. Continuous monitoring. Performance regression detection. Release confidence.
IAB Tier 2 Subcategory Distribution
Top Websites Using web-vitals
| Website | IAB Category | Subcategory | OpenRank |
|---|---|---|---|
| linkedin.com | Business and Finance | Career Advice | 10 |
| microsoft.com | Technology & Computing | Computing | 7.82 |
| etsy.com | Shopping | Personal Celebrations & Life Events | 7.33 |
| cnn.com | News and Politics | International News | 7.09 |
| archive.org | Fine Art | Amharic | 6.97 |
| squarespace.com | Business and Finance | Marketplace/eCommerce | 6.74 |
| oracle.com | Business and Finance | Industries | 6.55 |
| netflix.com | Television | Reality TV | 6.5 |
| lifehacker.com | Food & Drink | Cookbooks | 6.48 |
| lastpass.com | Family and Relationships | Computing | 6.2 |
Web Vitals Integration Examples
Installation
npm install web-vitals
# Or via CDN
# https://unpkg.com/web-vitals
Basic Usage
import { onCLS, onINP, onLCP, onFCP, onTTFB } from 'web-vitals';
// Measure Core Web Vitals
onCLS(console.log); // Cumulative Layout Shift
onINP(console.log); // Interaction to Next Paint
onLCP(console.log); // Largest Contentful Paint
// Additional metrics
onFCP(console.log); // First Contentful Paint
onTTFB(console.log); // Time to First Byte
// Each callback receives a metric object:
// {
// name: 'LCP',
// value: 2500,
// rating: 'needs-improvement',
// delta: 2500,
// entries: [...],
// id: 'v3-1234567890'
// }
Send to Analytics
import { onCLS, onINP, onLCP } from 'web-vitals';
function sendToAnalytics(metric) {
// Google Analytics 4
gtag('event', metric.name, {
value: Math.round(metric.name === 'CLS' ? metric.value * 1000 : metric.value),
event_category: 'Web Vitals',
event_label: metric.id,
non_interaction: true
});
// Or custom endpoint
const body = JSON.stringify({
name: metric.name,
value: metric.value,
rating: metric.rating,
delta: metric.delta,
id: metric.id,
page: window.location.pathname
});
// Use sendBeacon for reliability
if (navigator.sendBeacon) {
navigator.sendBeacon('/analytics/vitals', body);
} else {
fetch('/analytics/vitals', { body, method: 'POST', keepalive: true });
}
}
onCLS(sendToAnalytics);
onINP(sendToAnalytics);
onLCP(sendToAnalytics);
Attribution for Debugging
import { onLCP, onCLS, onINP } from 'web-vitals/attribution';
onLCP((metric) => {
console.log('LCP:', metric.value);
console.log('Element:', metric.attribution.element);
console.log('Resource URL:', metric.attribution.url);
console.log('Time to first byte:', metric.attribution.timeToFirstByte);
console.log('Resource load delay:', metric.attribution.resourceLoadDelay);
});
onCLS((metric) => {
console.log('CLS:', metric.value);
metric.attribution.largestShiftSources.forEach(source => {
console.log('Shifted element:', source.node);
console.log('Previous rect:', source.previousRect);
console.log('Current rect:', source.currentRect);
});
});
onINP((metric) => {
console.log('INP:', metric.value);
console.log('Interaction target:', metric.attribution.interactionTarget);
console.log('Interaction type:', metric.attribution.interactionType);
console.log('Input delay:', metric.attribution.inputDelay);
console.log('Processing time:', metric.attribution.processingDuration);
console.log('Presentation delay:', metric.attribution.presentationDelay);
});
Report All Metrics
import { onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';
const vitalsUrl = 'https://analytics.example.com/vitals';
function sendToEndpoint({ name, delta, value, id, rating }) {
const body = JSON.stringify({ name, delta, value, id, rating });
(navigator.sendBeacon && navigator.sendBeacon(vitalsUrl, body)) ||
fetch(vitalsUrl, { body, method: 'POST', keepalive: true });
}
// Report all metrics
onCLS(sendToEndpoint);
onFCP(sendToEndpoint);
onINP(sendToEndpoint);
onLCP(sendToEndpoint);
onTTFB(sendToEndpoint);
React Integration
// In Next.js: pages/_app.js
import { useEffect } from 'react';
import { onCLS, onINP, onLCP } from 'web-vitals';
export function reportWebVitals(metric) {
switch (metric.name) {
case 'CLS':
case 'INP':
case 'LCP':
console.log(metric);
sendToAnalytics(metric);
break;
default:
break;
}
}
// Or manual setup in any React app
function App() {
useEffect(() => {
onCLS(console.log);
onINP(console.log);
onLCP(console.log);
}, []);
return ;
}
Usage by Domain Popularity (Top 1M)
Usage by Domain Age
The average age of websites using web-vitals is 10.6 years. The average OpenRank (measure of backlink strength) is 2.84.
Why Developers Choose Web Vitals
Google Standard: Official Google metrics. Search ranking factors. Industry-standard measurements. Consistent definitions.
Real User Data: Production measurements. Actual user experiences captured. Beyond lab testing. True performance picture.
Lightweight: Minimal bundle impact. No performance overhead. Efficient implementation. Production-safe.
Easy Integration: Simple API. Quick setup. Major frameworks supported. Analytics-ready format.
Debugging Support: Attribution build available. Element identification. Root cause data. Actionable insights.
SEO Benefits: Core Web Vitals affect rankings. Competitive advantage. User experience alignment. Business impact.
Active Maintenance: Google maintained. Regular updates. New metrics added. Evolving with web standards.
Emerging Websites Using web-vitals
| Website | IAB Category | Subcategory | OpenRank |
|---|---|---|---|
| silvertipdigital.com | Business and Finance | Business | 0 |
| makeyourmarkcelebrations.com | Automotive | Auto Body Styles | 0 |
| discountmattresslady.com | Shopping | Travel Type | 0 |
| westlawholesale.com | Business and Finance | Arts and Crafts | 0 |
| fuck-china.com | Sports | Extreme Sports | 0 |
Technologies Less Frequently Used with web-vitals
| Technology | Co-usage Rate | Website |
|---|---|---|
| 51.LA | 0% | https://www.51.la |
| A8.net | 0% | https://www.a8.net |
| Accessible360 | 0% | https://accessible360.com |
| AdaSiteCompliance | 0% | https://adasitecompliance.com |
| Adobe Flash | 0% | https://www.adobe.com/products/flashplayer |