Lesson 2 of 30
A slow interaction and a slow event handler aren't always the same bug. Splitting INP into its three parts tells you whether the handler is guilty, or just an innocent bystander on a busy main thread.
13 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 3
A developer optimizes a click handler's own code to run faster, but the interaction's INP doesn't improve. What's the most likely explanation given what you know about INP's three parts?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
You already know INP measures how long the page takes to visibly respond to an interaction. What you can't tell from the single number is where the time went — and that matters, because the fix for "the handler itself is slow" is completely different from the fix for "something unrelated was blocking the thread when the click happened." Chrome's tooling splits every interaction into three sequential parts:
The diagnostic value is specific: a high Input Delay means you should be hunting for other long tasks on the page, not optimizing this handler. A high Processing Time means the handler itself genuinely needs to do less work, or defer some of it.
// Somewhere else on the page, unrelated to the button:
function ProductList({ items }) {
// A large, expensive re-render or a long synchronous computation
// running on every parent re-render — not triggered by the click below,
// but occupying the main thread whenever it happens to run.
const sorted = expensiveSort(items);
return <ul>{sorted.map(renderItem)}</ul>;
}
function AddToCartButton() {
// This handler is fast — a couple of milliseconds of actual work.
function handleClick() {
addToCart(productId);
}
return <button onClick={handleClick}>Add to cart</button>;
}
A click happens. The next frame paint is the finish line for INP.
If AddToCartButton's click feels sluggish, it's tempting to assume handleClick is slow and start optimizing it — but if expensiveSort happens to be running (triggered by an unrelated state update) at the exact moment the user clicks, the browser can't start handleClick until that unrelated work finishes. That shows up entirely as Input Delay, not Processing Time. Optimizing handleClick further would do nothing; the actual fix is breaking up or deferring expensiveSort so the main thread is free more often.
requestIdleCallback-style deferral, or moving pure computation to a Web Worker) genuinely helps."This button feels laggy — how do you find out why?" tests whether a candidate defaults to reading the handler's code (easy to get wrong) or actually measures where the delay lands across Input Delay, Processing Time, and Presentation Delay first.