INP replaced FID, and here is what I had to fix
On March 12, Interaction to Next Paint (INP) replaced First Input Delay (FID) as a Core Web Vital.
On March 12, Interaction to Next Paint (INP) replaced First Input Delay (FID) as a Core Web Vital. If your Search Console report suddenly went from green to orange, you’re in good company. FID was an easy metric to pass. INP is a much more honest one.
What changed
FID only measured the delay before the browser could start handling the very first interaction on the page. It didn’t care how long your handler took, or how long the screen took to update afterwards. And it ignored every interaction after the first one.
INP looks at every click, tap and key press during the whole visit. For each one, it measures the time from the input until the next frame is painted. The page’s INP is roughly the slowest of those. On pages with lots of interactions, a few outliers are ignored.
| INP | Rating |
|---|---|
| 200 ms or less | good |
| 200 to 500 ms | needs improvement |
| over 500 ms | poor |
Each interaction has three parts, and you fix them differently:
- Input delay: the main thread is busy with something else when the user clicks.
- Processing time: your event handlers run.
- Presentation delay: the browser recalculates styles and layout and paints the result.
Measuring it in the field
Lab tools only see the interactions you happen to try. Real users find the slow ones for you, so measure there. The web-vitals library has an attribution build that tells you which element was involved:
import { onINP } from 'web-vitals/attribution';
onINP(({ value, rating, attribution }) => {
navigator.sendBeacon(
'/analytics',
JSON.stringify({
inp: Math.round(value),
rating,
target: attribution.eventTarget, // a CSS selector for the element
type: attribution.eventType, // e.g. 'pointerup', 'keydown'
loadState: attribution.loadState,
}),
);
});
After a few days, group by target. The bad interactions are usually concentrated in a handful of places: a filter panel, a big dropdown, an “add to cart” button that does too much.
loadState is worth keeping too. If the slow interactions mostly happen while the page is still loading, the problem is input delay from too much startup JavaScript, not your click handler.
Fix 1: show something, then do the work
The most common pattern I see is a click handler that does everything synchronously before the browser can paint:
filterButton.addEventListener('click', () => {
filterButton.classList.add('active');
applyFilters(); // re-renders a long list, 400 ms
});
The user sees nothing until applyFilters finishes, and INP counts all of it. Split it so the visual feedback gets painted first:
function yieldToMain() {
if (globalThis.scheduler?.yield) {
return scheduler.yield();
}
return new Promise((resolve) => setTimeout(resolve, 0));
}
filterButton.addEventListener('click', async () => {
filterButton.classList.add('active');
await yieldToMain(); // let the browser paint the button state
applyFilters();
});
The total work is the same, but the next paint happens right after the class change, and that’s what INP measures. scheduler.yield() is in an origin trial in Chrome right now, so the helper checks for it and falls back to setTimeout.
In React 18 you get a similar effect by wrapping the expensive state update in startTransition. In Angular, moving noisy listeners out of the zone helps with input delay.
Fix 2: break up long loops
When the work itself is long, give the browser regular chances to handle input:
async function processAll(items) {
let lastYield = performance.now();
for (const item of items) {
process(item);
if (performance.now() - lastYield > 50) {
await yieldToMain();
lastYield = performance.now();
}
}
}
Yielding after every item adds overhead. Yielding every 50 ms or so keeps each task short enough that a click never waits long.
Fix 3: don’t make the browser lay out twice
Presentation delay is often layout work you cause by accident. Reading a layout value right after changing styles forces the browser to calculate layout immediately, and doing it in a loop forces it again and again:
// forces a layout on every iteration
for (const row of rows) {
row.style.height = `${row.scrollHeight}px`;
}
// read everything first, then write
const heights = rows.map((row) => row.scrollHeight);
rows.forEach((row, i) => {
row.style.height = `${heights[i]}px`;
});
The Performance panel in DevTools shows this as purple “Layout” blocks with a warning triangle. Large DOMs make every layout slower, so a list with thousands of rows often needs virtualisation as well.
Fix 4: move work that the user doesn’t wait for
Analytics calls, saving to localStorage, prefetching the next page: none of these need to happen before the paint. Defer them:
button.addEventListener('click', () => {
updateUi();
setTimeout(() => {
trackEvent('add_to_cart');
saveCartToStorage();
}, 0);
});
This one is easy to miss because third-party scripts often attach their own handlers to the same clicks. In the Performance panel, look at everything that runs inside the interaction, not just your own code.
Where to start
Get field data first, find the two or three slowest interactions, and record each one in the Performance panel. In my experience, most fixes come down to the same idea: paint first, work later.