Orofold Labs

Launching soon

Notes Get in touch

Performance and accessibility 4 min read Updated

Fixing Interaction to Next Paint, long tasks first

In short

Find which of the three delay parts dominates each slow interaction, then shorten long tasks and keep event handlers light.

A page can load quickly and still feel broken if every button takes half a second to react. Interaction to Next Paint (INP) measures the time from a click, tap or key press until the screen shows the result. Before you change any code, find out which of the three parts of that time is the longest.

Know the thresholds first

An INP of 200 milliseconds or less is rated good. Above 500 milliseconds it is poor, and anything in between needs improvement. The guidance measures the 75th percentile of page loads, reported separately for mobile and desktop, so a fast desktop result can hide a slow result on a phone.

Each interaction has three parts

INP observes the latency of all qualifying interactions during a visit and reports the longest one, ignoring outliers: on pages with many interactions, the highest one is ignored for every 50 interactions. Clicks, key presses and taps all count. Each interaction can be split into three parts:

  • Input delay: the time from when the user starts the interaction until its event callbacks begin to run.
  • Processing duration: the time the event callbacks take to run to completion.
  • Presentation delay: the time from the end of the callbacks until the browser paints the next frame that shows the result.

The three parts add up to the total latency of one interaction. A long input delay often points to busy scripts during startup. A long processing duration points to heavy event handlers. A long presentation delay is often linked to a large DOM or expensive rendering.

Break long tasks into smaller pieces

Any task longer than 50 milliseconds is a long task, and long tasks can block input. Script evaluation during page load is a common source, so keep long tasks to a minimum while the page starts. When work during an interaction cannot be avoided, split it into smaller pieces and yield to the main thread between them. The guidance mentions scheduler.yield() where the browser supports it, and a setTimeout-based fallback otherwise. Yielding is better than not yielding, even though a deferred task goes to the back of the queue.

Working on something similar in your own product? A few honest sentences are enough – we read every enquiry and reply by email. Apply with your idea

Keep event handlers light

An event handler should do the minimum needed to show the result. Inside the callback, apply only the visual change needed for the next frame. Move other work, such as saving data or running a spell check, to a later task. Avoid reading layout values right after changing styles in the same task, because that forces the browser to calculate layout synchronously. Take care when rendering large amounts of HTML on the client during an interaction, since the browser does not yield until parsing and rendering finish.

A large DOM slows every update

A large DOM makes rendering more expensive, both on load and during interactions. The guidance suggests flattening the structure, adding content incrementally during an interaction rather than all at once, and using content-visibility so that off-screen elements render only when needed.

A practical checklist

  1. Before changing code, find the slowest interactions in your field data, reported separately for mobile and desktop.
  2. For each slow interaction, identify which of the three parts dominates.
  3. If input delay is high, reduce script work during load and find the long tasks at startup.
  4. If processing duration is high, move work that is not visual out of the handler, and yield between steps.
  5. If presentation delay is high, reduce the DOM size and the work the browser must do for the next frame.
  6. Test the same interaction again on a mid-range phone, not only on a development laptop.

If the page loads scripts from other companies, check their cost as well; see The real cost of third-party scripts. For the loading side of speed, read fixing Largest Contentful Paint one delay at a time, and for the general picture, speed as part of design.

Common questions

Which INP value is good?
A value of 200 milliseconds or less is good, above 500 milliseconds is poor, and anything in between needs improvement. The guidance measures the 75th percentile of page loads, separately for mobile and desktop.
What counts as a long task?
Any task that takes longer than 50 milliseconds. Long tasks can block input and make a page feel unresponsive.
Should I yield to the main thread with setTimeout?
The guidance says yielding is better than not yielding at all. Where the browser supports scheduler.yield(), it is mentioned as the option, and a setTimeout-based fallback works otherwise.

Sources

  1. Optimize Interaction to Next Paint, web.dev (Google). Accessed 24 November 2026
  2. Optimize long tasks, web.dev (Google). Accessed 24 November 2026

Further reading

Have an idea that should exist? Or a working product that needs more customers, a new website or a complete rework? Bring us anything. Apply with your idea

All notes