# Web Vitals

Browser performance metrics, thresholds, and where kogut reports them.

The [tracking script](https://docs.kogut.dev/web-apps/tracking-script/) measures page performance in visitors'
browsers. A metric the browser does not support has no samples.

## Metrics and thresholds

| Metric | Measures | Good | Poor |
|---|---|---|---|
| LCP, Largest Contentful Paint | Main content appears | ≤ 2.5 s | > 4 s |
| INP, Interaction to Next Paint | Response to clicks, taps, and keys | ≤ 200 ms | > 500 ms |
| CLS, Cumulative Layout Shift | Layout movement | ≤ 0.1 | > 0.25 |
| FCP, First Contentful Paint | First content appears | ≤ 1.8 s | > 3 s |
| TTFB, Time to First Byte | First document byte arrives | ≤ 0.8 s | > 1.8 s |

kogut rates the 75th percentile (p75). Values between the thresholds are rated "needs
improvement".

## Measurement methods

- LCP uses the last entry before the first interaction or page hide.
- INP keeps the ten longest interactions and skips one per 50 interactions.
- CLS reports the worst window of shifts less than one second apart, up to five seconds
  long. Shifts after recent input do not count.
- FCP and TTFB use paint and navigation timing, relative to prerender activation.

The script sends values once when the page hides, exits, or changes route; see
[single-page apps](https://docs.kogut.dev/web-apps/single-page-apps/).

## View Web Vitals

**Analytics** has an **LCP p75** chart and a **Web Vitals** card with all five metrics,
sample counts, and ratings. The `vitals` list in `GET /api/v1/analytics` and the
[MCP](https://docs.kogut.dev/reference/mcp/) `analytics` tool return the same.
[Deploy reports](https://docs.kogut.dev/deploys/reports/) compare them before and after a deploy.

Percentiles come from hourly histograms. Retention is set in
[`[retention]`](https://docs.kogut.dev/reference/configuration/#retention).
