Skip to content

This notebook belongs to

Sadat Jubayer

Senior Software Engineer at Premio

If found, please return to hello@jubayer.dev

Vol. 7Seven years of building

Started
January 2020
Everyday tools
TypeScript, Vue, React, Next.js, NestJS, React Native
Education
B.Sc. CSSE, AIUB, 2020
2 min readPerformanceWeb Platform

Measure INP in the field by phase

INP replaced FID as a Core Web Vital in 2024. Log it from real visits with web-vitals and read input delay, processing, and presentation delay.

Search Console says a page has poor INP. You open it, click around, and nothing feels slow. The number comes from real visitors on real devices, so you need to measure it where they are.

INP replaced First Input Delay as a Core Web Vital in March 2024. A page is good at 200 ms or less, measured at the 75th percentile of visits, and poor above 500 ms. For most visits INP uses the slowest interaction. The metric ignores one of the slowest interactions for every 50 interactions on the page.

Log it from your own pages

The web-vitals library has an attribution build that breaks each INP value into parts. Install it with pnpm add web-vitals and import onINP from web-vitals/attribution in your bundled client code.

import { onINP } from 'web-vitals/attribution'

onINP(
  ({ value, rating, attribution }) => {
    console.log({
      inp: Math.round(value),
      rating,
      target: attribution.interactionTarget,
      inputDelay: Math.round(attribution.inputDelay),
      processingDuration: Math.round(attribution.processingDuration),
      presentationDelay: Math.round(attribution.presentationDelay),
    })
  },
  { reportAllChanges: true }
)

To reproduce this locally, click a Save button with a handler that runs for about 300 ms. One Chromium run produced these values.

{
  "inp": 320,
  "rating": "needs-improvement",
  "target": "#save",
  "inputDelay": 0,
  "processingDuration": 301,
  "presentationDelay": 22
}

You now see the interaction's total, which element it was on, and how the time split.

reportAllChanges makes the callback fire each time the value changes, so you can see the result after the browser measures the interaction. Without it, the library reports a changed INP value when the page becomes hidden. A visit with no qualifying interaction has no INP report.

Read the three phases

The INP guide defines an interaction as three consecutive parts. The big number tells you which part to open first.

  • inputDelay is the time before any callback for the interaction starts. A large value can indicate other work on the main thread when the user clicked.
  • processingDuration is the time for all the callbacks to run. A large value points you toward the event handlers and work they trigger. In my run this was 301 of 320 ms.
  • presentationDelay is the time from the end of the callbacks until the browser presents the next frame. A large value points you toward work between the handlers and the next paint, such as layout and rendering.

interactionTarget is a selector for the element the user interacted with. Group your reports by it and by the biggest phase, and you can see which elements are slow and why.

For field data, send the final value to an endpoint you control. The web-vitals reporting example uses navigator.sendBeacon() and leaves reportAllChanges off.

December 2025 update: The interactionId API used to group events for INP is now available across current browser engines. Older browsers can still lack it.