
In March 2024, Interaction to Next Paint (INP) replaced First Input Delay (FID) as a Core Web Vital. A lot of React apps that had perfect FID scores suddenly showed up as “needs improvement” or “poor”.
That wasn’t a coincidence. FID only measured the delay before your first event handler started. INP measures the whole interaction, from the click until the next frame is actually painted, across the entire visit. React apps that do a lot of rendering work after each click were finally getting measured honestly.
Here’s how I find the slow interaction, figure out which part of it is slow, and fix it.
What INP actually measures
INP looks at clicks, taps, and key presses (not scrolling or hovering). For each one, it measures how long until the browser paints the next frame. Your INP score is roughly the slowest interaction during the page visit. For pages with lots of interactions, a few extreme outliers are ignored, so one freak hiccup won’t define your score.
| Rating | INP |
|---|---|
| Good | 200 ms or less |
| Needs improvement | 200-500 ms |
| Poor | Over 500 ms |
Like the other Core Web Vitals, it’s assessed at the 75th percentile of real user visits. That means your fast MacBook is not the benchmark. Your users’ mid-range Android phones are.
The three phases

This is the most useful thing to understand about INP. Every slow interaction is slow in one (or more) of three phases, and each phase has a completely different fix:
- Input delay: the user clicked, but the main thread was busy doing something else, so your handler couldn’t even start.
- Processing duration: your event handlers are running. In React, this includes the re-render your state update triggers.
- Presentation delay: handlers are done, but the browser still has to recalculate styles, lay out, and paint the frame.
If you skip this diagnosis and jump straight to “add useMemo everywhere”, you’ll often fix the wrong phase.
Step 1: Find the slow interactions in the field
Lab tools are great for debugging, but you need real-user data to know which interactions to debug. The web-vitals library has an attribution build that tells you which element was involved and how long each phase took:
import { onINP } from 'web-vitals/attribution';
onINP(({ value, rating, attribution }) => {
const {
interactionTarget, // CSS selector of the element, e.g. "#filters > button.apply"
interactionType, // "pointer" or "keyboard"
inputDelay,
processingDuration,
presentationDelay,
loadState, // was the page still loading?
} = attribution;
navigator.sendBeacon('/analytics/inp', JSON.stringify({
value, rating, interactionTarget, interactionType,
inputDelay, processingDuration, presentationDelay, loadState,
page: location.pathname,
}));
});
After a few days, group by interactionTarget and look at the p75. You’ll usually find that two or three interactions are responsible for most of the problem. In my experience it’s often a filter, a tab switch, or opening a big menu or modal.
Also look at loadState. If a lot of slow interactions happen while the page is still loading, your problem is probably input delay caused by hydration and third-party scripts, not your click handler.
Step 2: Reproduce it in DevTools
- Open the Chrome DevTools Performance panel. It shows live INP as you interact with the page.
- Turn on CPU throttling (4x or 6x slowdown) to approximate a mid-range phone.
- Record, perform the slow interaction, and stop.
- Find the interaction in the Interactions track. Hover it to see the phase breakdown, and look at the main thread flame chart underneath.
Now you know which phase is slow and what code is running during it.
Fixing input delay
The main thread was busy when the user clicked. Common culprits: hydration, big third-party scripts, analytics, and long tasks from timers or data processing.
The fix is to break long tasks into smaller pieces and let the browser handle input in between. That’s called yielding:
function yieldToMain() {
if (globalThis.scheduler?.yield) return scheduler.yield();
return new Promise((resolve) => setTimeout(resolve, 0));
}
async function processInChunks(items, processItem) {
let lastYield = performance.now();
for (const item of items) {
processItem(item);
// Yield roughly every 50ms so a click never waits long.
if (performance.now() - lastYield > 50) {
await yieldToMain();
lastYield = performance.now();
}
}
}
scheduler.yield() is supported in Chromium-based browsers and continues your task with priority ahead of other queued work, which is why it’s preferred over a plain setTimeout. The fallback still works everywhere.
Other fixes for input delay: defer non-critical third-party scripts, lazy-load below-the-fold components, and reduce how much JavaScript needs to hydrate on load.
Fixing processing duration
This is the classic React problem. A click updates state, and that state update re-renders a huge part of the tree synchronously before the browser can paint.
Do the urgent part first, and the rest as a transition.
function ProductSearch({ products }) {
const [query, setQuery] = useState('');
const [filterQuery, setFilterQuery] = useState('');
const [isPending, startTransition] = useTransition();
function handleChange(e) {
setQuery(e.target.value); // urgent: the input updates immediately
startTransition(() => {
setFilterQuery(e.target.value); // non-urgent: React can interrupt this render
});
}
return (
<>
<input value={query} onChange={handleChange} />
<div style={{ opacity: isPending ? 0.6 : 1 }}>
<ProductGrid products={products} query={filterQuery} />
</div>
</>
);
}
The input stays responsive because React treats the expensive grid render as interruptible. useDeferredValue gives you the same effect if you can’t change where the state is set.
Other fixes for processing:
- Do less in the handler. Analytics calls, logging, and syncing to localStorage can happen after the paint. Wrap them in
yieldToMain()orrequestIdleCallback. - Stop unnecessary re-renders. Check whether one state update in a context provider re-renders the whole app. I explain the usual causes in React rendering and re-renders.
- Move heavy computation to a Web Worker. Sorting 50,000 rows or parsing a large file doesn’t belong on the main thread.
- Debounce work tied to typing. See debounce vs throttle.
Fixing presentation delay
Your JavaScript is done, but the browser is spending a long time on style, layout, and paint. This usually means too many DOM nodes or expensive layout.
- Virtualize long lists. Rendering 5,000 rows is slow to lay out no matter how fast your JavaScript is. See list virtualization.
- Use
content-visibility: autoon large off-screen sections so the browser skips their rendering work. - Avoid layout thrashing. Reading
offsetHeightright after writing styles in a loop forces repeated synchronous layouts. - Be careful with huge style recalculations, like toggling a class on
bodythat affects thousands of elements.
Where AI features make this worse
If you’ve built a streaming AI chat, you’ve probably created an INP problem without noticing. Every token triggers a state update and a markdown re-parse. While the response streams, the main thread stays busy, and typing in the input or clicking Stop feels sluggish.
The fixes are the same principles: batch token updates once per animation frame, isolate the streaming message so the rest of the list doesn’t re-render, and only re-parse the markdown block that’s still changing. I walk through the code in how to stream LLM responses in the browser.
Interview angle
Performance comes up in almost every frontend system design round. “I’d measure Core Web Vitals” is a junior answer. Here’s what a stronger one sounds like:
“I’d collect INP from real users with attribution, so I know which interaction is slow and which phase. If it’s input delay, I’d break up long tasks and defer third-party scripts. If it’s processing, I’d make the expensive render a transition or move work off the main thread. If it’s presentation, I’d shrink the DOM with virtualization.”
That shows you understand the metric, not just its name. For a broader overview of all three Core Web Vitals, see the free Core Web Vitals guide on FrontendLead. For the React performance questions that usually follow, see 300+ React interview questions and answers.
And that’s it, folks. INP is the most honest performance metric we’ve had for interactive apps. Measure it in the field, find the phase, and fix that phase.
