Skip to content

How to avoid long main-thread tasks

Speed1 min readFixes check long-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.

How to fix it.
  1. Find the scripts behind the longest tasks (listed below) and defer, split or remove them.
  2. Yield to the browser between chunks of work (setTimeout, scheduler.yield, requestIdleCallback).

Filed under Speed & Core Web Vitals. Copy is generated from the same catalogue that scores every report, so what you read here is what the report says.