Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

Interaction to Next Paint: Long Animation Frames, Long Tasks and Main-Thread Scheduling

How INP measures responsiveness, how the Long Animation Frames API finds causes, and how to break up long main-thread work.

This page summarises Chrome for Developers guidance on Interaction to Next Paint (INP)—the Core Web Vital for responsiveness—and on diagnosing slow interactions in production with the Long Animation Frames API (LoAF), breaking up long tasks, and related Scheduler API patterns from Modern Web Guidance.

Interaction to Next Paint (INP): what it measures and why it matters

Section titled “Interaction to Next Paint (INP): what it measures and why it matters”

INP scores how quickly a page responds across its whole lifetime (including single-page app soft navigations until a hard navigation or tab close). It is built on the Event Timing API and reflects the worst interaction (with outliers removed), not a single lab click.

Poor responsiveness to interactions leads to a poor impression of a page being slow or even completely broken. Interaction to Next Paint (INP) is a metric based on the Event Timing API. It measures the worst interaction (minus some outliers) as a measure of the page’s responsiveness.

— Chrome, Identify causes of poor INP

Field INP often tracks lab Total Blocking Time (TBT): long main-thread JavaScript after an interaction delays the next paint. Typical contributors include unoptimised or bloated scripts, third-party code, stacked event handlers, framework hydration, and aggressive prefetch that renders routes synchronously—see How modern frameworks perform on the new INP metric.

Lab tools replay only a fraction of real interactions; measuring causes in the field is essential.

INP subparts: input delay, processing duration, presentation delay

Section titled “INP subparts: input delay, processing duration, presentation delay”

The Event Timing API splits INP into three subparts:

Subpart What it usually indicates
Input delay Work already running on the main thread when the user acts
Processing duration JavaScript and logic tied directly to the interaction
Presentation delay Style, layout, and paint before the next frame

The Event Timing API allows for splitting the INP duration into three subparts: Input Delay (processing that is already happening when the interaction happens), Processing Duration (delays due as a direct result of the interaction), and Presentation Delay (delays that are due to rendering the next frame after the interaction).

— Chrome, Identify causes of poor INP

Use subparts first to see whether to fix other code, the handler, or rendering—not only the handler you wrote.

Long Animation Frames API vs long tasks: which view to use in the field

Section titled “Long Animation Frames API vs long tasks: which view to use in the field”

Long tasks are main-thread tasks of 50 ms or longer. They correlate with sluggish input, but field attribution is thin:

The Long Tasks API only has a basic attribution model, which at best only tells you the container the long task happened in (the top-level document or an <iframe>), but not the script or function which called it

— Chrome, Long Animation Frames API

Several sub-50 ms tasks in one frame can still block rendering without any single long task entry.

The Long Animation Frames API (LoAF) is a new API that seeks to address some of the shortcomings of the Long Tasks API to enable developers to get more actionable insights to help address responsiveness problems and improve INP, as well as get insights into smoothness issues.

— Chrome, Long Animation Frames API

A long animation frame is a rendering update delayed beyond 50 ms (same threshold as long tasks). LoAF records frame duration, blockingDuration, render phases, and per-script attribution (for scripts over 5 ms on the main thread, same-origin).

Field Role
duration Total frame work (smoothness, jank)
blockingDuration Time the frame blocks input/high-priority work (INP)
firstUIEventTimestamp Whether a UI event was processed in the frame
scripts[] sourceURL, invoker, invokerType, forced style/layout times

For the common 60 hertz display, a browser will try to schedule a frame at least every 16.66 milliseconds … However, if there is no input—nor other high-priority tasks—but there is a queue of other tasks, the browser will typically continue the current frame well past 16.66 milliseconds

— Chrome, Long Animation Frames API

Frames with low or zero blockingDuration can still feel responsive to input; reducing blockingDuration by splitting work is central to INP. Many long frames by duration still hurt scroll and animation smoothness.

Browser support: LoAF ships in Chrome and Edge 123+; unsupported browsers ignore observers safely. Prefer LoAF over the JS Self-Profiling API for production attribution (Identify causes of poor INP).

Register a PerformanceObserver with buffered: true (buffer size 200, same as long tasks):

if (PerformanceObserver.supportedEntryTypes.includes('long-animation-frame')) {
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
// Filter, summarise, beacon to analytics
}
});
observer.observe({ type: 'long-animation-frame', buffered: true });
}

Patterns from Long Animation Frames API and Identify heavy-running JavaScript:

  • LoAFs with firstUIEventTimestamp > 0 and high blockingDuration (often near the 200 ms “good” INP bar).
  • Aggregate scripts[].sourceURL by total duration to find repeat offenders.
  • Keep only the worst N frames to limit beacon size.

The INP LoAF is the long animation frame tied to the slowest interaction; one interaction can span two or more LoAFs. The web-vitals web-vitals/attribution build exposes intersecting LoAFs on onINP().

Break up long tasks: scheduler.yield() and the 50 ms rule

Section titled “Break up long tasks: scheduler.yield() and the 50 ms rule”

Heavy loops and DOM updates block input. Chrome’s Break Up Long Tasks guide treats 50 ms as when a slice becomes a long task:

Heavy computations or long loops can block the main thread, causing the page to become unresponsive. To prevent this, you should yield control back to the browser periodically. The scheduler.yield() API allows you to pause a long task and let the browser handle user input or rendering before continuing.

— Chrome, Break Up Long Tasks

Modern Web Guidance — Performance summarises a practical split:

Work length Approach
< 50 ms Run synchronously
50–250 ms Slice; await scheduler.yield() (or fallback)
> 250 ms Prefer a Web Worker
async function processLargeArray(items) {
let deadline = performance.now() + 50;
for (const item of items) {
processItem(item);
if (performance.now() >= deadline) {
if ('scheduler' in window && 'yield' in window.scheduler) {
await scheduler.yield();
} else {
await new Promise((resolve) => setTimeout(resolve, 0));
}
deadline = performance.now() + 50;
}
}
}

Prioritised scheduling and isInputPending()

Section titled “Prioritised scheduling and isInputPending()”

Schedule Tasks By Priority uses scheduler.postTask() with user-blocking, user-visible (default), and background (analytics, prefetch).

navigator.scheduling.isInputPending() let JavaScript check for pending input without always yielding (Chromium 87+ only). Chrome now warns:

Important: The recommended usage of this API has changed since this document was originally published. Conditional yielding on user input is no longer recommended. For more details see the Optimizing Long Tasks article.

— Chrome, Better JS scheduling with isInputPending()

Treat scheduler.yield() and explicit time budgets as the primary pattern; use isInputPending() only with discretion and known limitations (cross-origin iframes, shared event loops on Android).

Inside scripts, forcedStyleDuration / forcedLayoutDuration on LoAF script entries flag layout thrashing (read/write interleaving). High styleDuration vs layoutDuration on frames points to CSS invalidation vs geometry cost (Identify causes of poor INP).

Non-composited animations can add jank and CLS; compositor-only animations are excluded from CLS (Avoid non-composited animations).

Field measurement: web-vitals, visibility, soft navigations, beacons

Section titled “Field measurement: web-vitals, visibility, soft navigations, beacons”

Calculating INP from raw Event Timing is error-prone; use a RUM library. onINP from web-vitals/attribution reports subparts, longest script, and LoAF data—beacon summaries to your endpoint rather than logging only locally (Identify causes of poor INP).

Distinguish forced style/layout inside scripts from render-phase style/layout summed across LoAF entries when explaining high presentation delay.

RUM skews if you count background tabs. Use performance.getEntriesByType('visibility-state') for foreground time and initial background detection (Calculate total foreground time, Detect Initial Visibility State). Checking only document.visibilityState at script run can miss a tab that was opened in the background then foregrounded.

CrUX ad sampling pauses when the tab is backgrounded (CrUX ad metrics measurement methodology).

Chrome defines a soft navigation as user-initiated, with a visible URL change and visible paint (Measuring soft navigations). soft-navigation and interaction-contentful-paint entries (Chrome 151+) let you slice LCP, INP, and CLS per client-side route; match paints with interactionId, not only navigationId (Measure interaction and soft-navigation paint timing).

Until soft-nav support is universal, INP and CLS on SPAs still often accumulate for the full tab lifetime without reset on route change—similar to current Core Web Vitals behaviour noted in CrUX ad metrics methodology. The web-vitals library reportSoftNavs: true (v6+) handles many edge cases; CrUX exposes experimental soft-nav vitals (Metrics — CrUX methodology).

Send exit beacons with fetchLater() (batch with activateAfter and AbortController) instead of fragile unload handlers (Debounce and batch multiple analytics events, Reliably measure full-session analytics and telemetry). Respect roughly 64 KB per-origin quota and feature-detect with a polyfill when needed.

  • Optimising only the INP LoAF and missing other high-blockingDuration frames that will become the next worst interaction (Long Animation Frames API).
  • Assuming long-task counts equal INP fixes; split work and measure LoAF blockingDuration.
  • Layout thrashing and expensive selectors in interaction paths inflate processing and presentation delay.
  • Third-party and hydration work on the critical path after every click (How modern frameworks perform on the new INP metric).
  • RUM that ignores background visibility or loses the last SPA beacon on old browsers (Cloudflare Web Analytics FAQ).
  1. Run Lighthouse or Chrome DevTools Performance on a throttled device; note long tasks and check audits such as avoiding non-composited animations where relevant.

  2. In DevTools, record an interaction that feels slow and inspect main-thread activity; optionally surface LoAF with performance.measure() as in Long Animation Frames API.

  3. Deploy web-vitals/attribution onINP() (or your RUM vendor’s INP breakdown) and segment by inputDelay, processingDuration, and presentationDelay.

  4. Correlate field data with Chrome User Experience Report (including experimental soft-navigation vitals if you use SPAs).

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact wording you are asking about.