INPCore Web VitalsTBTAI AgentsPerformance

How to Fix Interaction to Next Paint (INP) with AI

Fix slow Interaction to Next Paint (INP) using Lighthouse AIReport JSON and AI coding agents. Trace TBT long tasks, script bootup, and event handlers.

PageSpeed Exporter Team··5 min read

Interaction to Next Paint (INP) measures how quickly your page visually responds after a user clicks, taps, or presses a key—and Google requires 200 ms or less at the 75th percentile (p75) to pass Core Web Vitals. To fix INP with an AI coding agent, export a stripped AIReport (<50KB) from PageSpeed Exporter, read fieldData to confirm real-user INP, and use scorePlan + bootup-time + long-tasks to eliminate the main-thread JavaScript blocking interactions.

INP Thresholds and the Lab Proxy (TBT)

Because Lighthouse runs an automated page load without human clicks, INP is field-only (reported in fieldData from CrUX). In the lab, Total Blocking Time (TBT) is the direct proxy—and TBT carries 30% of your Lighthouse performance score.

MetricWhere MeasuredGoodNeeds ImprovementPoor
| INP (Core Web Vital) | CrUX fieldData (28-day real users) | ≤ 200 ms | 200–500 ms | > 500 ms |

| TBT (Lab proxy, 30% weight) | Lighthouse lab scorePlan | ≤ 200 ms (mobile) | 200–600 ms | > 600 ms |

If your fieldData shows INP > 200 ms, fixing lab TBT and heavy event handlers is what moves both your Lighthouse score and real-user responsiveness.


Step 1: Export a Stripped AIReport (or Call MCP)

Run your slow URL on Mobile at speedexporter.com and click Download AIReport (JSON)—or let Claude Code, Cursor, or Windsurf call analyze_url via our MCP server.

Inside the <50KB AIReport, check four fields:

  1. fieldData.url / fieldData.origin: Confirms real-user INTERACTION_TO_NEXT_PAINT p75 latency.
  2. scorePlan.strategies[].metrics: Shows total-blocking-time's numericValue, pointsAtRisk, and targetFor90 (200 ms on mobile, 150 ms on desktop).
  3. issues[] affecting TBT: Look for bootup-time, mainthread-work-breakdown, long-tasks, unused-javascript, and third-party-summary.
  4. details.items & fixLocation: Names the exact script URL, source modules, and whether the culprit is first-party code or third-party (thirdParty: true, entity).

Step 2: Prompt Your AI Agent to Break Up Long Tasks

Attach the AIReport to Claude, ChatGPT, or Cursor with this prompt:

The attached JSON is a stripped PageSpeed Exporter AIReport for [URL].
Our real-user INP is failing (> 200 ms).

1. Check fieldData for INP and scorePlan for total-blocking-time (numericValue, pointsAtRisk, targetFor90).
2. List the top culprit scripts from bootup-time, long-tasks, and mainthread-work-breakdown.
3. Separate first-party code (fixLocation: "code" or "build-config") from thirdParty entities.
4. For each first-party culprit, give me exact code diffs to:
   - Yield to the main thread inside heavy event handlers (scheduler.yield() or setTimeout fallback)
   - Code-split or defer non-critical hydration/bundles
   - Avoid forced synchronous layouts (read DOM measurements before writing styles)
5. For third-party scripts, show how to defer or load them after interaction instead of editing remote files.

The 4 Code Fixes That Move INP the Most

1. Yield to the Main Thread in Heavy Handlers

Any synchronous task over 50 ms blocks the browser from painting the next frame after a click or keypress. Yield back to the browser before heavy work:

async function yieldToMain(): Promise<void> {
  if ('scheduler' in globalThis && 'yield' in (globalThis as { scheduler?: { yield?: () => Promise<void> } }).scheduler!) {
    return (globalThis as { scheduler: { yield: () => Promise<void> } }).scheduler.yield();
  }
  return new Promise((resolve) => setTimeout(resolve, 0));
}

export async function handleFilterChange(items: Product[], query: string) {
  // 1. Update lightweight UI state immediately so the browser paints feedback
  setInputValue(query);
  await yieldToMain();

  // 2. Run the expensive filtering/sorting in the next task
  setFiltered(expensiveFilter(items, query));
}

2. Defer Third-Party Widgets (Chat, Analytics, Tag Managers)

If bootup-time flags thirdParty: true entities (Intercom, HubSpot, GTM, review widgets), defer them until after hydration or user interaction. In Next.js, use next/script with strategy="lazyOnload" or afterInteractive; in plain HTML, load non-critical scripts with defer or on first interaction.

3. Shrink Hydration & Unused JavaScript

Large client bundles cause hydration long tasks that block early clicks. Move static UI to Server Components (in Next.js), lazy-load modals/charts with dynamic() or React.lazy(), and remove unused modules flagged in details.items[].modules.

4. Eliminate Layout Thrashing Inside Click Handlers

Reading offsetHeight or getBoundingClientRect() immediately after mutating styles forces synchronous layout recalculation inside the interaction frame. Batch DOM reads first, then apply CSS class or transform writes.


Step 3: Re-scan and Verify

Deploy your patch and re-scan the same mobile URL in PageSpeed Exporter:

  • Lab gate: total-blocking-time.numericValue ≤ 200 ms (mobile) and ≤ 150 ms (desktop on Starter/Pro).
  • Culprit check: The offending script's scripting duration in bootup-time drops sharply or disappears from long-tasks.
  • Field tracking: Remember fieldData INP will not change on the same day—check CrUX and Google Search Console over the next 2–4 weeks as real user sessions refresh.

Further Reading


Sources

Frequently Asked Questions

What is a good Interaction to Next Paint (INP) score?

Google considers INP good at 200 milliseconds or less at the 75th percentile (p75) of real Chrome users. Between 200 ms and 500 ms needs improvement, and above 500 ms is poor.

Why doesn't INP appear in Lighthouse lab metrics?

INP requires real user interactions (clicks, taps, key presses), so it is a field-only CrUX metric. In Lighthouse lab runs, Total Blocking Time (TBT) is the official lab proxy — bringing mobile TBT to 200 ms or less is the fastest way to improve real-user INP.

How long does it take for INP fixes to show up in Google Search Console?

Google Search Console and CrUX fieldData aggregate a rolling 28-day window of real Chrome visits. After deploying a fix and confirming lab TBT is 200 ms or less, expect 1 to 4 weeks for field INP to reflect the improvement.


Further reading

Try it yourself

Run a free Lighthouse audit on any URL and export a stripped AIReport JSON under 50KB for your AI agent — no account required.

Analyze a URL for free