How to Improve INP: A Practical Guide to Interaction to Next Paint
Find the interactions that make your site feel slow, and fix them with measurable, framework-agnostic techniques
Why INP Is the Core Web Vital Most Sites Fail
You click "Add to cart" and nothing happens for half a second. Then the button finally changes. That pause is what Interaction to Next Paint (INP) measures: the time from a user's click, tap or key press until the browser paints the next frame showing a response.
INP replaced First Input Delay (FID) as a Core Web Vital on March 12, 2024. FID only measured the delay before the first interaction's handler started. INP measures the full latency of interactions across the whole visit, so pages that passed FID easily often fail INP.
Google's thresholds, measured at the 75th percentile of page visits:
- Good: 200 milliseconds or less
- Needs improvement: 200 to 500 milliseconds
- Poor: more than 500 milliseconds
Core Web Vitals are part of Google's page experience signals, but the bigger reason to care is users. Slow responses make an interface feel broken, and people click again, abandon forms and leave. This guide takes you from "Search Console says INP is poor" to the specific line of code causing it, then through the fixes that matter for each part of an interaction.
It assumes you understand the JavaScript event loop. If tasks and the main thread are new to you, read that first.
How INP Is Measured
Which interactions count
INP observes clicks, taps and key presses (including on-screen keyboards). Hovering, scrolling and zooming are not counted. Each interaction may fire several events, such as pointerdown, pointerup and click. The interaction's latency is the longest of them.
Which interaction becomes "the" INP
For most pages, INP is simply the slowest interaction during the visit. On pages with a great many interactions, the browser ignores one highest interaction for every 50, so a single random hiccup in a long session does not define the score. The value reported for your site is then the 75th percentile across all visits, split by mobile and desktop.
The three phases of an interaction
Every interaction's latency is the sum of three parts. Knowing which part is large tells you what to fix:
- Input delay: from the user's action until your event handlers start running. Long when the main thread is busy with other work, such as a third-party script or a large task during page load.
- Processing duration: the time your event handlers themselves take to run.
- Presentation delay: from the end of your handlers until the next frame is painted. Long when the browser has a lot of style, layout and paint work to do, often because of a large DOM or a big re-render.
A useful rule of thumb: any task longer than 50 milliseconds is a long task, and long tasks are the root of most INP problems.
Step 1: Find the Slow Interactions in the Field
Lab tools like Lighthouse cannot measure INP because there is no real user interacting. You need field data, measurements from real visitors.
- Google Search Console's Core Web Vitals report and PageSpeed Insights show whether URLs pass, using Chrome UX Report data. They tell you which pages are slow, not which interactions.
- To find the interactions, collect your own data with Google's web-vitals library. Its attribution build tells you which element was interacted with 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. "button.add-to-cart"
interactionType, // "pointer" or "keyboard"
inputDelay,
processingDuration,
presentationDelay,
longAnimationFrameEntries, // which scripts were running
} = attribution;
navigator.sendBeacon("/analytics/inp", JSON.stringify({
value, rating, interactionTarget, interactionType,
inputDelay, processingDuration, presentationDelay,
page: location.pathname,
}));
});After a few days, group the data by interactionTarget and look at the 75th percentile. You will usually find that a handful of interactions, such as a filter dropdown, a menu toggle or an add-to-cart button, account for almost all poor scores. The phase breakdown then tells you which of the next three sections to read.
Commercial RUM tools such as Vercel Speed Insights, DebugBear or SpeedCurve collect the same data if you prefer not to build a pipeline.
Step 2: Reproduce It in Chrome DevTools
Once you know which interaction is slow, reproduce it locally:
- Open Chrome DevTools and go to the Performance panel. Its live metrics view shows the INP of interactions on the current page as you use it, along with a log of each interaction.
- Enable CPU throttling (4× or 6× slowdown). Your laptop is far faster than the mid-range phones that dominate the 75th percentile. Without throttling, many INP problems simply don't show up.
- Start a recording, perform the slow interaction, and stop.
- Find the interaction in the Interactions track. Its bar shows the input delay, processing and presentation phases.
- Look at the main-thread flame chart under it. Long tasks are highlighted with red striping. Click into them to see which functions, and which files, took the time.
Pay attention to purple "Recalculate Style" and "Layout" blocks. If they are large, or appear repeatedly inside one task, you are looking at a presentation delay or layout thrashing problem. The DevTools tutorial covers the Performance panel basics.
Fix Input Delay: Free Up the Main Thread
If input delay is the largest phase, your handler is waiting behind other work. Common culprits:
- Third-party scripts: tag managers, chat widgets, A/B testing tools and ad scripts that run large tasks at unpredictable times. Audit them, remove the ones nobody uses, and load the rest with
deferor after the page is interactive. - Hydration and start-up work: frameworks that run a large task during load, exactly when users first try to tap something. Use code splitting so each page only loads and evaluates the JavaScript it needs.
- Timers and polling:
setIntervalcallbacks that do heavy work every few seconds collide with user input. Make them cheaper, or move the work to a Web Worker.
<!-- Load non-critical third-party code after the page is interactive -->
<script>
window.addEventListener("load", () => {
requestIdleCallback(() => {
const s = document.createElement("script");
s.src = "https://widget.example.com/chat.js";
document.body.append(s);
});
});
</script>requestIdleCallback is not available in every Safari version, so fall back to setTimeout where it is missing. Anything that does not need the DOM (parsing large JSON, sorting big lists, image processing) belongs in a worker, where it cannot block input at all.
Fix Processing Duration: Yield to the Main Thread
If your own event handler is slow, the biggest win is usually not making it faster but splitting it up. Do the work that changes what the user sees first, then yield so the browser can paint, then do the rest.
function yieldToMain() {
if (globalThis.scheduler?.yield) {
return scheduler.yield();
}
return new Promise((resolve) => setTimeout(resolve, 0));
}
addToCartButton.addEventListener("click", async () => {
// 1. Visible feedback first
addToCartButton.textContent = "Added ✓";
updateCartBadge();
// 2. Let the browser paint that feedback
await yieldToMain();
// 3. Everything else
sendAnalyticsEvent("add_to_cart");
syncCartWithServer();
updateRecommendations();
});scheduler.yield() is supported in Chrome and Edge 129+ and Firefox 142+. It pauses your function and resumes it with priority over other queued tasks, so you don't lose your place behind unrelated work. Safari did not support it in 2026, which is why the setTimeout fallback is there.
Break up loops
The same pattern works for loops over large data sets:
async function renderRows(rows) {
let lastYield = performance.now();
for (const row of rows) {
renderRow(row);
if (performance.now() - lastYield > 40) {
await yieldToMain();
lastYield = performance.now();
}
}
}Yielding roughly every 40–50ms keeps each task under the long-task threshold without slowing the total work much.
Avoid redundant work
- Debounce handlers on text inputs, so a search filter runs once after typing pauses rather than on every keystroke. Our throttle and debounce tutorial shows how.
- Use event delegation instead of attaching hundreds of listeners. See event delegation.
- Don't use
isInputPending(). Google no longer recommends it. Yielding regularly is simpler and more reliable.
Fix Presentation Delay: Make Rendering Cheaper
If handlers finish quickly but the frame still appears late, the browser is spending its time on style, layout and paint.
Avoid layout thrashing
Layout thrashing, or forced synchronous layout, happens when you change styles and then read layout values in the same task, repeatedly. Each read forces the browser to recalculate layout immediately.
// Slow: write, read, write, read... forces layout on every iteration
items.forEach((item) => {
item.style.width = container.offsetWidth / 3 + "px";
});
// Fast: read once, then write
const third = container.offsetWidth / 3;
items.forEach((item) => {
item.style.width = third + "px";
});Keep the DOM small
Style and layout cost grows with the number of elements affected. Pages with tens of thousands of nodes, often from long product grids, mega menus or comment threads, have slow presentation delays everywhere. Paginate or virtualise long lists, and don't render hidden UI until it is needed.
Skip rendering off-screen content
content-visibility: auto lets the browser skip layout and paint for sections that are off-screen until the user scrolls near them:
.article-section {
content-visibility: auto;
contain-intrinsic-size: auto 600px; /* estimated height, avoids scrollbar jumps */
}Prefer cheap visual changes
Toggling a class that changes transform or opacity is far cheaper than one that changes layout properties for a large subtree. See CSS performance optimization for which properties trigger layout.
React and Framework-Specific Fixes
In component frameworks, slow interactions are usually caused by re-rendering too much: one state change at the top of the tree re-renders hundreds of components before anything is painted.
- Mark non-urgent updates as transitions. In React,
startTransition(or theuseTransitionhook) lets the urgent update, such as the input's new value, paint first, while the expensive update, such as filtering a big list, renders afterwards and can be interrupted by further typing. - Defer expensive derived values with
useDeferredValue, so a slow list re-renders after the input updates. - Keep state local. State stored high in the tree, or in a context that many components read, makes every interaction re-render everything below it.
- Memoise expensive children with
memoonce profiling shows they re-render unnecessarily. The React DevTools Profiler shows exactly which components rendered and why. - Don't ship work on the client that can run on the server. Server rendering and server components reduce both hydration cost (input delay) and client re-render cost.
Vue, Svelte and Angular have equivalent tools: computed or derived state, fine-grained reactivity and lazy-loaded routes. The principle is the same everywhere: render the smallest possible change before the next paint.
Monitor Long Animation Frames in Production
The Long Animation Frames API (LoAF), available in Chrome and Edge 123+, reports frames that took longer than 50ms to produce, along with the scripts that ran during them. The web-vitals attribution build already includes these entries for the INP interaction, but you can also observe them directly:
const observer = new PerformanceObserver((list) => {
for (const frame of list.getEntries()) {
if (frame.duration < 150) continue;
for (const script of frame.scripts) {
console.log({
source: script.sourceURL,
fn: script.sourceFunctionName,
invoker: script.invoker, // e.g. "BUTTON.onclick"
duration: Math.round(script.duration),
forcedLayout: Math.round(script.forcedStyleAndLayoutDuration),
});
}
}
});
observer.observe({ type: "long-animation-frame", buffered: true });sourceURL is what makes LoAF so useful: it tells you whether the slow code is yours or a third party's. forcedStyleAndLayoutDuration points straight at layout thrashing. Send a sample of these entries to your analytics alongside INP, and you will have the evidence to fix the problem or confront the vendor.
A Prioritised INP Checklist
Work through these in order. The early items fix the most sites for the least effort.
- Collect field data with the web-vitals attribution build and find the slowest
interactionTargetvalues. - Reproduce each slow interaction in DevTools with 4× CPU throttling.
- Remove or defer third-party scripts that create long tasks.
- In slow handlers, update the UI first and yield with
scheduler.yield()(with asetTimeoutfallback) before doing the rest. - Move non-DOM work, such as parsing, sorting and computation, to a Web Worker.
- Fix layout thrashing: batch DOM reads before writes.
- Reduce DOM size and add
content-visibility: autoto long pages. - In React, use transitions and deferred values, and keep state local.
- Monitor Long Animation Frames in production so regressions are caught early.
Re-check the 75th percentile after each change. Field data in Search Console updates over a rolling 28-day window, so improvements take a few weeks to show up there. Your own RUM data shows the effect within days.
Key Takeaways
- INP measures click, tap and key press latency. Good is 200ms or less at the 75th percentile.
- Every interaction has three phases: input delay, processing duration and presentation delay. Fix the largest one.
- You need field data. The web-vitals attribution build tells you the element and the phase breakdown.
- Reproduce with CPU throttling. Fast developer machines hide INP problems.
- Show feedback first, then yield.
scheduler.yield()with asetTimeoutfallback is the most effective single technique. - Third-party scripts, large DOMs and over-rendering frameworks cause most poor INP.
Your next step: add the onINP attribution snippet to your site today. In a week, you will know exactly which interaction to fix first.
Frequently Asked Questions
What is a good INP score?
200 milliseconds or less at the 75th percentile of page visits is good. 200 to 500 milliseconds needs improvement, and anything above 500 milliseconds is poor. Scores are assessed separately for mobile and desktop.
When did INP replace FID?
Interaction to Next Paint replaced First Input Delay as a Core Web Vital on March 12, 2024. Unlike FID, which only measured the delay before the first interaction was handled, INP measures the full latency of interactions throughout the visit.
Why doesn't Lighthouse show my INP?
INP requires real user interactions, so lab tools like Lighthouse cannot measure it. Lighthouse reports Total Blocking Time as a rough lab proxy. Use field data from Search Console, PageSpeed Insights or the web-vitals library to measure INP.
What causes poor INP?
Usually long tasks on the main thread: heavy third-party scripts, large JavaScript bundles evaluated at start-up, slow event handlers, framework re-renders and expensive layout from a large DOM or layout thrashing.
What is scheduler.yield() and can I use it?
scheduler.yield() pauses a long-running function so the browser can handle input and paint, then resumes it with high priority. It is supported in Chrome and Edge 129+ and Firefox 142+. Use it with a setTimeout fallback for other browsers.
Does INP affect SEO rankings?
INP is one of Google's Core Web Vitals, which are part of its page experience signals. Relevance and content quality matter far more for ranking, but a poor INP harms user experience and conversions, which is reason enough to fix it.
References and Further Reading
- Interaction to Next Paint (INP) · web.dev
- Optimize Interaction to Next Paint · web.dev
- Optimize long tasks · web.dev
- Long Animation Frames API · Chrome for Developers
- web-vitals library · GoogleChrome on GitHub
- Scheduler: yield() method · MDN Web Docs
Related Articles
Continue your learning journey with these related topics