# 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.

Speed & Core Web Vitals · HTML version: https://getreport.app/learn/long-tasks

## Long main-thread tasks

Passing looks like: No long main-thread tasks block interaction.

**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).

Check your own page: https://getreport.app/
