惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
B
Blog RSS Feed
C
Check Point Blog
D
Docker
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
量子位
有赞技术团队
有赞技术团队
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
M
MIT News - Artificial intelligence
B
Blog
阮一峰的网络日志
阮一峰的网络日志
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
腾讯CDC
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
V2EX
月光博客
月光博客

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
INP for React Apps: Profiling and Eliminating Long Tasks
Nayan Kyada · 2026-05-21 · via DEV Community

INP (Interaction to Next Paint) measures how quickly your UI responds after a user interacts.
If a click, tap, or keypress is followed by a noticeable delay, you’ll feel it — and so will your users.

INP is now the key responsiveness metric in Core Web Vitals, and it’s one of the most common issues on React apps that ship too much JavaScript.

What INP actually measures (in plain terms)

When a user interacts, the browser has to:

  1. run your event handler,
  2. run any state updates and rendering work,
  3. paint the next frame.

INP captures the time from interaction to the next paint for the worst interactions users experience (within a page view).

Targets (baseline)

  • Good: ≤ 200ms
  • Needs improvement: 200–500ms
  • Poor: > 500ms

The main causes of bad INP in React apps

In most apps, INP is bad because of one or more of these:

  • Long tasks (main thread blocked for >50ms)
  • Render storms (too many components re-rendering)
  • Heavy work inside event handlers (sync parsing, sorting, filtering)
  • Third-party scripts (analytics, chat widgets, tag managers)
  • Too much JS shipped (hydration costs + runtime overhead)

You don’t “optimize INP” by tweaking one thing — you reduce main-thread work and make updates cheaper.

Step 0: Confirm you really have an INP problem

Start with field data:

  • Search Console’s Core Web Vitals report (pattern-level)
  • RUM if you have it (best)

Then use lab tools to reproduce:

  • Chrome DevTools Performance recording
  • React DevTools Profiler

Step 1: Find long tasks (your #1 enemy)

If the main thread is blocked, the browser can’t paint.

How to spot them

In a Performance recording:

  • Look for long yellow blocks (scripting).
  • Zoom into interactions and check what runs right after the input event.

If you see repeated long tasks, you’ve found your INP root cause.

Step 2: Make event handlers “light”

Event handlers should ideally:

  • update state,
  • schedule work,
  • and return quickly.

Common anti-patterns

  • Doing expensive filtering/sorting synchronously on click
  • Parsing large JSON payloads during input
  • Building huge arrays/objects during a scroll/typing event

Fix patterns

  • Precompute when possible (outside the interaction)
  • Debounce expensive work triggered by typing
  • Chunk big work into smaller pieces

Step 3: Reduce React re-render costs

Many INP problems are simply “too much renders happen per interaction”.

What I check first

  • Are we passing new objects/functions every render?
  • Are lists re-rendering on every keystroke?
  • Is global state causing whole pages to update?

Fix patterns that consistently help

  • Memoize hot components (only where it matters)
  • Use stable props (avoid {} and () => {} inline for hot paths)
  • Split state: keep “typing state” local, not global
  • Virtualize big lists/grids

The goal isn’t to “memo everything”. The goal is to stop re-rendering 200 components when the user clicks one button.

Step 4: Reduce hydration + client JS on content pages

If your page is mostly content (blog posts), you usually don’t need much JS.

Best lever

Avoid turning layout/typography into client components.

Ship interaction only where needed (search box, filters, forms), and keep everything else server-rendered.

Step 5: Defer third-party scripts (they often dominate INP)

Third-party scripts can easily:

  • add long tasks,
  • create layout thrash,
  • or block the main thread during interaction.

Practical strategy

  • Defer until after first interaction or idle
  • Load only on routes that need it
  • Remove anything you don’t use weekly

Most teams keep scripts forever. INP improves fast when you treat scripts like dependencies with a cost.

Step 6: Use a repeatable INP “playbook”

This is my default workflow:

  1. Identify a bad interaction (field data or user report).
  2. Reproduce in DevTools.
  3. Find the longest task after the input event.
  4. Reduce work in the handler.
  5. Reduce re-renders triggered by that state update.
  6. Re-test and confirm the long task is gone.

Quick checklist

  • Event handlers return quickly
  • Expensive work is deferred/chunked
  • Large lists are virtualized
  • Hot components are memoized appropriately
  • Client JS is minimized on content routes
  • Third-party scripts are deferred/audited