---
title: "Interaction to Next Paint and TTFB, measured from real visits and fixed"
description: "Interaction to Next Paint (INP) is the time from a click, tap, or key press to the next paint. Time to First Byte (TTFB) is the wait for the first byte of the page."
canonical: "https://logbrew.co/en/guides/web-vitals"
last_updated: "2026-11-25"
---

# Interaction to Next Paint and TTFB, measured from real visits and fixed

Interaction to Next Paint (INP) is the time from a click, tap, or key press to the next paint. Time to First Byte (TTFB) is the wait for the first byte of the page.

Tested on November 25, 2026 with Chrome 157, @logbrew/browser 0.1.25, @logbrew/sdk 0.1.48, web-vitals 6.2.3, and logbrew CLI 0.1.96

By [Furkan Erday](https://github.com/furkanerday). Furkan Erday is the founder of LogBrew. He builds LogBrew with Claude Code and Codex every day.

Canonical: https://logbrew.co/en/guides/web-vitals

## What INP and TTFB showed for each change

| Page load | Rated good | Span names the slow part |
| --- | --- | --- |
| Click handler with 300 ms of work | INP 336 ms | Processing 304 ms |
| Handler that yields after the update | INP 40 ms | Presentation 36 ms |
| Server waits 600 ms | TTFB 609 ms | Total only |
| Server waits 1,900 ms | TTFB 1,908 ms | Total only |
| `301` redirect of 400 ms | TTFB 407 ms | Total only |

5 page loads of 1 checkout page in Chrome 157, with @logbrew/browser 0.1.25 and web-vitals 6.2.3.

## Record Web Vitals from real visits

### Install the SDK and web-vitals

`@logbrew/browser` turns each metric that the `web-vitals` library reports into a span of the page's trace. Use a browser key of your LogBrew project.

```bash
npm install @logbrew/sdk @logbrew/browser web-vitals
```

### Start the Web Vitals spans

The attribution build of `web-vitals` adds the input delay, the processing time, and the presentation delay of the slowest interaction to the INP span. `webVitalPathTemplate` puts every visit under 1 route name, so an order ID in the path does not split the numbers.

```bash
import {
  installLogBrewBrowser,
  installLogBrewBrowserWebVitalsInstrumentation
} from "@logbrew/browser";
import * as webVitals from "web-vitals/attribution";

const logbrew = installLogBrewBrowser({ clientKey: "LOGBREW_BROWSER_KEY" });

installLogBrewBrowserWebVitalsInstrumentation(logbrew, {
  metricNames: ["INP", "TTFB", "LCP", "CLS", "FCP"],
  webVitalPathTemplate: "/checkout",
  webVitals
});
```

### Read the Web Vitals of 1 visit

The SDK sends INP, LCP, and CLS when the tab goes to the background or closes, because a visitor can click until they leave. We opened our own pricing page in Chrome 157, opened 1 question, and left. The trace of that visit held 5 Web Vitals.

```bash
logbrew read trace aa60e9d3e3676ae490b8dcc4c088e47e --project "<project_id>"
```

Output

```text
Trace aa60e9d3e3676ae490b8dcc4c088e47e spans=7 [0d2bcbc7a055b019f491c875b8f40400f4eb73af / production]
- page_view /pricing
- browser.web_vital FCP /[locale]/pricing
- browser.document /[locale]/pricing
- browser.web_vital TTFB /[locale]/pricing
- browser.web_vital LCP /[locale]/pricing
- ... 2 more spans
```

### List INP across visits

Each Web Vital is also a metric, such as `browser.web_vital.inp`. The click on the question took 56 ms to paint, which is good.

```bash
logbrew read metrics --project "<project_id>" --name browser.web_vital.inp --since 10m
```

Output

```text
Metrics (1)
- browser.web_vital.inp histogram value=56.0 unit=ms temporality=delta service=logbrew-web trace=3266bca41da57f256dc33a96fad893ad span=bacd55722fff71b4 occurred=2026-11-25T09:58:17.254Z sdk=logbrew-web@0.1.18 [0d2bcbc7a055b019f491c875b8f40400f4eb73af / production]
```

## Fix a slow INP

### Find the slow part

An INP span splits the time into 3 parts. On our test checkout page, a click handler with 300 ms of work gave an INP of 336 ms. The processing time was 304.1 ms of it, so the handler was the cause. A long input delay points to other work on the main thread. A long presentation delay points to rendering.

Output

```text
"metricName": "INP",
"metricValue": 336,
"rating": "needs-improvement",
"inputDelayMs": 0.7,
"processingDurationMs": 304.1,
"presentationDelayMs": 31.2
```

### Update the page first, then yield

Show the result of the click first. Then give the main thread back with `scheduler.yield()`, so the browser paints before the rest of the work runs. Split long work into parts and yield between them. Not every browser has `scheduler.yield()`, so the code falls back to `setTimeout`.

```bash
const yieldToMain = () =>
  globalThis.scheduler?.yield
    ? scheduler.yield()
    : new Promise((resolve) => setTimeout(resolve, 0));

button.addEventListener("click", async () => {
  status.textContent = "Applying coupon…";
  await yieldToMain();
  for (const part of work) {
    part();
    await yieldToMain();
  }
  status.textContent = "Coupon applied";
});
```

### Measure the same click again

The handler did the same 300 ms of work in 6 parts of 50 ms. INP fell to 40 ms, and the processing time fell to 3 ms.

Output

```text
"metricName": "INP",
"metricValue": 40,
"rating": "good",
"inputDelayMs": 0.6,
"processingDurationMs": 3,
"presentationDelayMs": 36.4
```

## Reduce TTFB

### Find where the wait starts

We made our test server wait before it sent the page, as a slow database query does. TTFB followed the wait. It was 3 ms with no wait, 609.3 ms with 600 ms, and 1,907.5 ms with 1,900 ms. The last one is poor, and First Contentful Paint moved to 2,004 ms with it. A TTFB span gives only the total, so add a `Server-Timing` header to see the time of each server step.

### Remove redirects

A visit to `/old-checkout` went through a `301` redirect that took 400 ms. TTFB was 406.6 ms, because TTFB counts the redirect too. Link straight to the final address.

### Serve the page from a cache near the visitor

A CDN keeps a copy of the page on servers close to the visitor, so the request skips the trip to your server. Cache pages that are the same for every visitor, and stream the HTML so the first bytes leave before the whole page is ready.

## What we saw when we tested it

We built 1 checkout page with @logbrew/browser 0.1.25 and web-vitals 6.2.3, and loaded it 5 times in Chrome 157 on macOS. A local server sent the page and kept each request the SDK sent. We then read 1 visit of logbrew.co back from LogBrew, where @logbrew/browser 0.1.24 runs.

Only the click handler that yielded gave a good INP. A server wait of 600 ms still gave a good TTFB, and a wait of 1,900 ms gave a poor one. Each INP span named its slowest part, and each TTFB span gave only the total.

- `page_view /pricing`
  - `INP`: `56 ms`
  - `TTFB`: `205 ms`
  - `LCP`: `444 ms`
  - `FCP`: `444 ms`
  - `CLS`: `0`

## Good INP and TTFB values

Google rates INP good at 200 ms or less and poor above 500 ms. It rates TTFB good at 800 ms or less and poor above 1,800 ms. Each rating uses the 75th percentile of page loads, so 1 slow visit in 4 can move a page out of good.

INP is a Core Web Vital, and it replaced First Input Delay. TTFB is not a Core Web Vital, but a slow TTFB delays every paint after it.

|  | Good | Poor | Core Web Vital |
| --- | --- | --- | --- |
| INP | ≤ 200 ms | > 500 ms | Yes |
| TTFB | ≤ 800 ms | > 1,800 ms | No |

## What INP counts

INP counts clicks, taps, and key presses. It does not count hover or scroll. For each interaction, it measures the input delay, the time the event handlers run, and the time until the next frame shows.

A lab test such as Lighthouse loads the page with no clicks, so it cannot measure INP. Only real visits give INP, which is why the SDK sends it from each visitor's browser.

|  | Counted in INP |
| --- | --- |
| Click | Yes |
| Tap | Yes |
| Key press | Yes |
| Hover | No |
| Scroll | No |

## Questions people ask

### What is INP?

INP, Interaction to Next Paint, is the time from a click, tap, or key press to the next frame the page paints. A page's INP is close to its slowest interaction of the visit.

### What is a good INP score?

200 ms or less is good, and more than 500 ms is poor. Google uses the 75th percentile of page loads. Our click handler with 300 ms of work gave 336 ms, and the same work in parts gave 40 ms.

### How do I reduce TTFB?

Remove redirects, cache pages near the visitor with a CDN, and make the server answer faster. In our test, each 1 ms that the server waited added about 1 ms to TTFB, and a 400 ms redirect added 400 ms.

### Is TTFB a Core Web Vital?

No. The Core Web Vitals are LCP, INP, and CLS. TTFB comes before all of them, so a slow TTFB also slows First Contentful Paint and LCP.

### Why does Lighthouse not show INP?

Lighthouse loads the page without clicks, taps, or key presses, so there is no interaction to measure. Record INP from real visits with the `web-vitals` library and a tool such as LogBrew.

## See the INP and TTFB of every page view

LogBrew keeps each Web Vital in the trace of its visit, next to the errors, logs, and requests of that page. Start on the generous free tier, no card needed.

[Start Free](https://logbrew.co/en)

## Sources

- [web.dev, Interaction to Next Paint (INP)](https://web.dev/articles/inp)
- [web.dev, Time to First Byte (TTFB)](https://web.dev/articles/ttfb)
- [web.dev, Optimize Time to First Byte](https://web.dev/articles/optimize-ttfb)
- [web.dev, Web Vitals](https://web.dev/articles/vitals)
- [MDN, Scheduler: yield() method](https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/yield)
- [GoogleChrome/web-vitals](https://github.com/GoogleChrome/web-vitals)
- [@logbrew/browser on npm](https://www.npmjs.com/package/@logbrew/browser)

## More guides for agents, Python, Node.js, and React

- [Claude Code MCP and Codex MCP server setup](https://logbrew.co/en/guides/mcp-server-claude-code-codex)
- [Use AGENTS.md in Claude Code and Codex](https://logbrew.co/en/guides/agents-md)
- [Fix the Claude overloaded error 529 and rate limit error 429](https://logbrew.co/en/guides/claude-overloaded-rate-limit-error)
- [Set up Python logging with the right log levels and exception capture](https://logbrew.co/en/guides/python-logging)
- [Structured logging with a log format and log levels you can search by field](https://logbrew.co/en/guides/structured-logging)
- [Set up the Pino logger or Winston in Node.js and keep every error](https://logbrew.co/en/guides/node-logging)
- [Set up Django logging and keep the traceback of every 500 error](https://logbrew.co/en/guides/django-logging)
- [Set up FastAPI logging and handle errors without losing the traceback](https://logbrew.co/en/guides/fastapi-logging)
- [Add a React error boundary and log the errors it misses](https://logbrew.co/en/guides/react-error-boundary)
- [Trace ID vs span ID, decoded from a real traceparent header](https://logbrew.co/en/guides/trace-id)
- [How to fix errors and set up logs, traces, metrics & releases](https://logbrew.co/en/guides)
