# `web-vitals`
- [Overview](#overview)
- [Install and load the library](#installation)
- [From npm](#import-web-vitals-from-npm)
- [From a CDN](#load-web-vitals-from-a-cdn)
- [Usage](#usage)
- [Basic usage](#basic-usage)
- [Report the value on every change](#report-the-value-on-every-change)
- [Report only the delta of changes](#report-only-the-delta-of-changes)
- [Send the results to an analytics endpoint](#send-the-results-to-an-analytics-endpoint)
- [Send the results to Google Analytics](#send-the-results-to-google-analytics)
- [Send the results to Google Tag Manager](#send-the-results-to-google-tag-manager)
- [Send attribution data](#send-attribution-data)
- [Batch multiple reports together](#batch-multiple-reports-together)
- [Build options](#build-options)
- [Which build is right for you?](#which-build-is-right-for-you)
- [How the polyfill works](#how-the-polyfill-works)
- [API](#api)
- [Types](#types)
- [Functions](#functions)
- [Rating Thresholds](#rating-thresholds)
- [Attribution](#attribution)
- [Browser Support](#browser-support)
- [Limitations](#limitations)
- [Development](#development)
- [Integrations](#integrations)
- [License](#license)
## Overview
The `web-vitals` library is a tiny (~1.5K, brotli'd), modular library for measuring all the [Web Vitals](https://web.dev/vitals/) metrics on real users, in a way that accurately matches how they're measured by Chrome and reported to other Google tools (e.g. [Chrome User Experience Report](https://developers.google.com/web/tools/chrome-user-experience-report), [Page Speed Insights](https://developers.google.com/speed/pagespeed/insights/), [Search Console's Speed Report](https://webmasters.googleblog.com/2019/11/search-console-speed-report.html)).
The library supports all of the [Core Web Vitals](https://web.dev/vitals/#core-web-vitals) as well as a number of other metrics that are useful in diagnosing [real-user](https://web.dev/user-centric-performance-metrics/) performance issues.
### Core Web Vitals
- [Cumulative Layout Shift (CLS)](https://web.dev/cls/)
- [First Input Delay (FID)](https://web.dev/fid/)
- [Largest Contentful Paint (LCP)](https://web.dev/lcp/)
### Other metrics
- [Interaction to next Paint (INP)](https://web.dev/inp/)
- [First Contentful Paint (FCP)](https://web.dev/fcp/)
- [Time to First Byte (TTFB)](https://web.dev/ttfb/)
## Install and load the library
The `web-vitals` library uses the `buffered` flag for [PerformanceObserver](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/observe), allowing it to access performance entries that occurred before the library was loaded.
This means you do not need to load this library early in order to get accurate performance data. In general, this library should be deferred until after other user-impacting code has loaded.
### From npm
You can install this library from npm by running:
```sh
npm install web-vitals
```
_**Note:** If you're not using npm, you can still load `web-vitals` via `
...