0Pricing
Web Performance Optimization & Lighthouse · Lezione

Interaction to Next Paint (INP)

Comprenda INP, il Core Web Vital che misura la reattività nel mondo reale, come venga calcolato durante una visita e quali tecniche mantengano rapide le interazioni.

Interaction to Next Paint (INP) è una lezione Web Performance Optimization & Lighthouse gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Web Performance Optimization & Lighthouse, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Web Performance Optimization & Lighthouse include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

Responsiveness as a Vital

Interaction to Next Paint (INP) measures how quickly the page visually responds to user input across the whole visit. It became a Core Web Vital, replacing First Input Delay.

INP vs FID

FID only measured the first interaction's input delay. INP is broader: it considers all interactions and the full latency through event handling and rendering, not just the initial delay.

What an Interaction Includes

Each interaction's latency spans three parts: input delay (waiting for the main thread), processing time (event handlers), and presentation delay (rendering the next frame).

How INP Is Reported

Across a visit, INP reports roughly the worst interaction latency (with an allowance for outliers on pages with many interactions), so it reflects the user's worst-case responsiveness.

The Thresholds

  • Good: 200ms or less
  • Needs improvement: 200-500ms
  • Poor: over 500ms

The Main Thread Is the Bottleneck

Long tasks block the main thread so input cannot be handled promptly. Breaking up long JavaScript tasks is the single biggest lever for improving INP.

Yielding to the Main Thread

Break long work into chunks and yield so the browser can handle input between them. scheduler.yield() or a setTimeout based yield helps.

async function process(items) {
  for (const item of items) {
    handle(item);
    await new Promise(r => setTimeout(r, 0));
  }
}

Defer Non-Urgent Work

Update the UI immediately for feedback, then run heavy work afterward. Patterns like requestAnimationFrame for visual updates and deferring analytics keep handlers short.

button.addEventListener('click', () => {
  showSpinner();
  setTimeout(doHeavyWork, 0);
});

Reduce Rendering Cost

The presentation phase suffers from large DOM updates and expensive layout. Use content-visibility, virtualization, and minimal DOM changes to render the next frame faster.

Measuring INP

Capture INP in the field with the web-vitals library, and use the DevTools Performance panel's interaction track to see input delay, processing, and presentation for each event.

import { onINP } from 'web-vitals';
onINP(metric => console.log('INP', metric.value));

Improvement Checklist

  • Break up long tasks and yield.
  • Defer non-urgent work after paint.
  • Trim event handler work.
  • Reduce DOM size and rendering cost.

Quick Check

How does INP differ fundamentally from the metric it replaced, FID?

Recap

You learned INP measures whole-visit responsiveness across input delay, processing, and presentation, with a good threshold of 200ms. Improve it by breaking up long tasks, yielding to the main thread, deferring non-urgent work, and reducing rendering cost.

Domande Frequenti

La lezione «Interaction to Next Paint (INP)» è gratuita?

Sì — il testo completo di «Interaction to Next Paint (INP)» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Web Performance Optimization & Lighthouse, passa a CoddyKit PRO. Il corso Web Performance Optimization & Lighthouse include 4 lezioni in totale.

Cosa imparerò in «Interaction to Next Paint (INP)»?

Comprenda INP, il Core Web Vital che misura la reattività nel mondo reale, come venga calcolato durante una visita e quali tecniche mantengano rapide le interazioni. Eserciti Web Performance Optimization & Lighthouse con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare Web Performance Optimization & Lighthouse?

Non è richiesta alcuna esperienza precedente. Web Performance Optimization & Lighthouse su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Interaction to Next Paint (INP)»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione Web Performance Optimization & Lighthouse?

Sì. Ogni lezione Web Performance Optimization & Lighthouse include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Introduzione ai Core Web Vitals
  2. Approfondimento su LCP, FID e CLS
  3. Miglioramento delle metriche di interazione
  4. Interaction to Next Paint (INP)
← Torna a Web Performance Optimization & Lighthouse