JavaScript · Performance · Senior · Concept
What are long tasks, and how do they relate to INP (Interaction to Next Paint)?
Short Interview Answer
Long tasks are main-thread blocks roughly >50ms; they delay event handling and rendering, hurting INP and responsiveness.
Detailed Explanation
INP measures how quickly the page responds visually to user interactions across the page lifetime. Heavy JS in click handlers, synchronous JSON parse, or hydration can inflate INP. Fixes: break work into chunks, defer non-essential work, move compute to workers, optimize handlers, avoid large style/layout in events. Use Long Tasks API / Performance panel to find culprits. Prioritize interaction paths over background analytics.
Interview Tip
Connect long tasks → delayed input → poor INP.
Common Mistake
Only optimizing LCP while ignoring interaction metrics.