How to avoid long main-thread tasks
Any script that runs longer than 50 ms freezes the page. Break work into smaller pieces and defer what is not needed for the first screen.
Step by step, with screenshots: How to fix Interaction to Next Paint (INP) and slow taps →
Check your own site
Runs this check and the other 186, free, in about 45 seconds.
What a passing site looks like
- No long main-thread tasks block interactionwarning · −2 ptseffort L
Long main-thread tasks
Why it matters. A task longer than 50 ms freezes the page for that long. Several in a row are what makes a site feel unresponsive to taps and scrolls.
- Find the scripts behind the longest tasks (listed below) and defer, split or remove them.
- Yield to the browser between chunks of work (setTimeout, scheduler.yield, requestIdleCallback).