What INP Measures
Interaction to Next Paint (INP) observes the latency of all click, tap, and keyboard interactions throughout a user’s visit and reports a value near the worst interaction latency. A good INP score is 200 milliseconds or less at the 75th percentile.
Every interaction consists of three phases:
- Input Delay: Time between the user’s click/keystroke and the event handler starting (caused by busy main-thread tasks).
- Processing Time: Execution duration of your JavaScript event callbacks.
- Presentation Delay: Time required for the browser to recalculate style, layout, paint, and composite the next frame.
Breaking Up Long Tasks on the Main Thread
Any JavaScript task running longer than 50ms blocks user input. Yield back to the browser’s main thread during heavy loops or multi-step UI updates using scheduler.yield() with a setTimeout fallback:
function yieldToMain() {
if ('scheduler' in window && 'yield' in scheduler) {
return scheduler.yield();
}
return new Promise((resolve) => setTimeout(resolve, 0));
}
async function processItems(items) {
for (let i = 0; i < items.length; i++) {
processSingleItem(items[i]);
if (i % 50 === 0) {
await yieldToMain();
}
}
}
Practical Checklist for Sub-200ms INP
- Provide Immediate Visual Feedback: Update button state or show a lightweight spinner synchronously in the event handler before starting async work.
- Avoid Layout Thrashing: Never interleave DOM writes (
el.style.width = ...) with synchronous layout reads (el.offsetHeight) inside loops. - Keep DOM Depth Lean: Pages with more than ~1,500 DOM nodes incur steep style-recalculation costs on every state change.
- Audit Third-Party Scripts: Tag managers and chat widgets frequently trigger long tasks during page load and user clicks.