INP is the latency from a user's click, tap or key press to the next frame painted, roughly the worst one in the visit. Good is ≤ 200 ms at p75. Every interaction has three phases: input delay (the main thread is busy with something else), processing time (your event handlers) and presentation delay (style, layout, paint and React commit work for the resulting update). Use field attribution to find the slow interaction and phase, then do less, yield sooner, and paint feedback first.
web-vitals/attribution reports the interaction target, event type, the three phases and, in Chromium, Long Animation Frame (LoAF) script attribution: which script URL and function ran.import { onINP } from 'web-vitals/attribution';
onINP(({ value, attribution: a }) => {
report({
value,
target: a.interactionTarget,
type: a.interactionType,
inputDelay: a.inputDelay,
processing: a.processingDuration,
presentation: a.presentationDelay,
scripts: a.longAnimationFrameEntries?.flatMap(f => f.scripts.map(s => s.sourceURL)),
});
});
Input delay
setInterval jobs.Processing time
button.addEventListener('click', async () => {
showSpinner(); // cheap visual feedback
await yieldToMain(); // let the browser paint
const result = expensiveFilter(data);
render(result);
queueAnalytics('filter'); // non-urgent work later
});
function yieldToMain() {
if (globalThis.scheduler?.yield) return scheduler.yield();
return new Promise(r => setTimeout(r, 0));
}
scheduler.yield() keeps your continuation at the front of the queue. Support is Chromium plus recent Firefox, so feature-detect it. In React, startTransition or useDeferredValue marks expensive re-renders as interruptible so typing stays responsive.
input events, but never debounce the visual echo of the keystroke itself.Presentation delay
content-visibility: auto for off-screen sections.async makes a handler non-blocking. Code before the first real await still runs synchronously, and so do the microtasks after it, all before the next paint.web-vitals, the LoAF API) leading to lab reproduction with CPU throttling.scheduler.yield with a fallback), React transitions, Workers, and DOM size.Spotted a mistake or a rights concern? Report an issue