Fix INP in Single-Page Applications, A Technical Guide

Learn how to audit and fix Interaction to Next Paint in complex single-page applications by addressing event handlers, main-thread blocking, and rendering pipeline issues.

Fix INP in Single-Page Applications, A Technical Guide

A single-page application with 200 milliseconds of Interaction to Next Paint on a developer’s MacBook can easily clock 600 ms on a median Android phone. That gap is where INP failures live. Google’s threshold is clear: under 200 ms is good, over 500 ms is poor, and everything in between needs work. Yet fixing INP on complex SPAs is not like optimizing Largest Contentful Paint or Cumulative Layout Shift. The bottleneck is not a single resource. It is the interplay between your event handlers, main-thread contention, and the rendering pipeline that fires after every user interaction. This article breaks down the specific patterns that cause poor INP scores and the engineering fixes that bring them under threshold.

Get a practitioner-led INP audit for your SPA before scores hurt rankings.

Request an INP audit

What INP actually measures (and why SPAs fail it)

INP captures the latency of the single worst interaction during a page’s lifecycle, from the moment a user taps, clicks, or presses a key to the moment the browser paints the visual result. It replaced First Input Delay in March 2024 as a Core Web Vital because FID only measured input delay for the first interaction. INP measures every interaction and reports the worst (or near-worst, using a high-percentile selection).

Traditional multi-page sites get a clean slate on each navigation. SPAs do not. A React, Angular, or Vue application accumulates state, event listeners, and DOM nodes over a session. The interaction that fails INP is often the fifteenth click, not the first. That is why lab testing with Lighthouse alone misses the problem. You need field data from the Chrome UX Report or the PerformanceObserver API to see what real users experience.

Auditing INP: a three-layer diagnosis

Every slow interaction has three components, and you need to measure each one separately. The total INP duration is the sum of input delay, processing time, and presentation delay. Fixing the wrong layer wastes engineering effort.

The most common misdiagnosis: engineers optimize the event handler code when the real bottleneck is input delay caused by unrelated background work, or presentation delay caused by a layout thrash the handler triggers indirectly.

1

Measure input delay with Long Animation Frames (LoAF):

Input delay is the time between the user’s action and the start of your event handler. It is almost always caused by something else occupying the main thread when the interaction arrives. Open Chrome DevTools, enable the Performance panel, and record a session that reproduces the slow interaction. Look for long tasks running before the event handler fires. The PerformanceObserver API with the "long-animation-frame" entry type will give you programmatic access to these frames in the field.

2

Isolate processing time with event handler profiling:

Processing time is the duration of your actual handler code, plus any synchronous work it triggers (state updates, derived computations, synchronous DOM reads). In the Performance panel, expand the interaction track and measure the gap between handler start and handler end. If your framework batches state updates (React’s setState, for example), the "processing" includes the synchronous reconciliation pass.

3

Quantify presentation delay through paint timing:

Presentation delay covers style recalculation, layout, paint, and compositing. This is the time between your handler completing and the browser producing the next frame. A handler that finishes in 20 ms can still produce a 300 ms INP if it triggers a massive layout recalculation across thousands of DOM nodes.

The five patterns that wreck INP in SPAs

After auditing dozens of complex SPAs, the same structural patterns recur. Here is what to look for.

1. Synchronous state derivation in event handlers. A click handler that filters a 10,000-item list, sorts it, and writes the result to reactive state before yielding. The framework then diffs the entire output. Total processing time: 150 to 400 ms on a mid-range device. The fix is to move the computation off the main thread using a Web Worker, or to break it into chunks using scheduler.yield() (available in Chromium and polyfillable).

2. Unthrottled scroll and resize listeners. An SPA that attaches scroll listeners for lazy loading, sticky headers, and analytics tracking. Each scroll event fires dozens of handlers. When the user then taps a button, the main thread is still processing the last batch of scroll work, creating input delay. The fix: use IntersectionObserver for visibility detection, ResizeObserver for dimension changes, and audit third-party scripts that add their own listeners.

3. Layout thrashing from interleaved reads and writes. A handler that reads offsetHeight, writes a style change, reads offsetHeight again, and writes another style change. Each read forces the browser to synchronously recalculate layout to return an accurate value. Batch all DOM reads first, then all DOM writes. Or use requestAnimationFrame to defer writes to the next frame.

4. Oversized component trees re-rendering. In React, a state change at a high level of the component tree causes reconciliation across hundreds of child components, even if most of them produce identical output. Angular’s default change detection strategy has the same problem. The rendering pipeline stalls because the framework is diffing a virtual DOM (or checking bindings) that is far larger than it needs to be.

5. Main-thread contention from analytics and personalization scripts. A/B testing platforms, session replay tools, and tag managers that execute synchronous JavaScript during idle periods. When those “idle” periods coincide with a user interaction, the interaction’s input delay spikes. Setting a performance budget for third-party scripts is the structural fix here.

Engineering fixes that move the needle

Knowing the patterns is half the work. The other half is applying fixes that do not destabilize your codebase. Here are the specific techniques, ordered by typical impact.

Yield to the main thread inside long handlers. The scheduler.yield() API lets you break a long task into smaller ones, giving the browser a chance to process pending interactions between chunks. If your handler takes 120 ms of processing, insert a yield after the critical visual update and defer the rest (analytics pings, prefetching, non-visible state updates). This single change can cut processing time by 50% or more from the user’s perspective because the browser can paint the critical update before the remaining work finishes.

Move heavy computation to Web Workers. Filtering, sorting, searching, and data transformation belong off the main thread. In an SPA, a dedicated worker that holds the canonical dataset and returns filtered results via postMessage eliminates the processing-time component entirely. The event handler becomes a message dispatch, completing in under 5 ms.

Virtualize long lists and large DOM trees. Libraries like TanStack Virtual (React), Angular CDK Virtual Scroll, and vue-virtual-scroller reduce the number of DOM nodes from thousands to dozens. Fewer nodes means faster style recalculation, faster layout, and faster paint. This directly shrinks presentation delay. If you are reducing Time to Interactive at the same time, virtualization helps there too.

Scope re-renders with memoization and signals. In React, wrap stable subtrees in React.memo and use useMemo / useCallback to prevent unnecessary reconciliation. Angular 16+ offers signals that provide fine-grained reactivity without zone.js overhead. Solid.js and Svelte do this by default through their compilation model. The goal is the same across frameworks: ensure that a state change only re-renders the components whose output actually changes.

Defer non-critical post-interaction work. After a user clicks “Add to Cart,” the only thing that needs to happen within 200 ms is the visual confirmation. The inventory check, the analytics event, the recommendation refresh, and the cart count animation can all happen after the next paint. Use requestIdleCallback, queueMicrotask, or scheduler.postTask with a background priority to schedule this work.

A good rule of thumb: if the user cannot see it within the current frame, it does not belong in the current task.

Validating your fixes in the field

Lab tools like Lighthouse and WebPageTest simulate a single interaction. They will not catch the interaction that fails at the 75th percentile in production. After deploying fixes, monitor real user metrics through the web-vitals JavaScript library or a RUM (Real User Monitoring) tool that reports INP at the interaction level, not just the page level.

Pay attention to the interaction type. Keyboard interactions on search fields, accordion toggles on mobile, and drag interactions in dashboards often have different bottleneck profiles. Segment your INP data by interaction target element and device class. A site speed optimization effort that only looks at aggregate numbers will miss regressions in specific user flows.

Set a target of 150 ms, not 200 ms. The “good” threshold has a buffer built in, and field conditions vary. Aiming for 150 ms gives you room for the inevitable entropy of new features and third-party script updates.

FAQs

What is a good INP score for a single-page application?

Google considers an INP under 200 ms “good.” For SPAs, aim for 150 ms or lower because accumulated state and DOM complexity make scores degrade over a session. Monitor the 75th percentile of field data, not lab averages.

Why does my SPA pass INP in Lighthouse but fail in the field?

Lighthouse typically tests a single interaction on a fast machine. Real users trigger many interactions across a session, on slower devices, with third-party scripts loaded. Field data from the Chrome UX Report or RUM tools captures the worst interactions that Lighthouse never simulates.

Can Web Workers fix INP problems?

Web Workers eliminate main-thread processing time for heavy computations like filtering, sorting, or data transformation. They do not help with presentation delay caused by large DOM updates. For best results, combine Workers with DOM virtualization and scoped re-renders.

How do third-party scripts affect INP?

Analytics, A/B testing, and session replay scripts run tasks on the main thread that compete with user interactions. When a script’s task overlaps with a click or keypress, it adds input delay. Audit third-party scripts regularly and load non-critical ones with lower scheduling priority.

Does switching from React to a signals-based framework improve INP?

Signals-based frameworks like Solid.js or Angular with signals offer finer-grained reactivity, which reduces unnecessary re-renders and shortens processing time. However, the framework alone does not guarantee good INP. Event handler design, DOM size, and third-party script management matter equally.

Get your SPA’s INP under threshold

Slow interactions cost conversions and search visibility. Our engineering team audits the exact handlers, tasks, and rendering patterns dragging your INP score down and ships the fixes.

Talk to our performance engineers