Lighthouse: Avoid long main-thread tasks
When any one of these tasks run for longer than 50 ms (also known as a "long task"), they can delay, both First Paint, and the time it takes for your page to become fully interactive.
Ensure that you avoid long main-thread tasks, as much as possible, to deliver a good page experience to your visitors.
How does your site score on this audit?
How do long main-thread tasks affect page performance?
Every time your page loads, the browser uses the main-thread to handle most of the tasks related to rendering your page content, as well as, deal with user interaction.
Long main-thread tasks prevent the browser from dealing with other processes that are essential in loading your page.
Decreasing the number of long main-thread tasks improves your overall page performance by minimizing main-thread work.
What this means for your visitors is, they may see content faster on your page and can interact with it sooner.
How does GTmetrix trigger this audit?
This audit is highly correlated with your Time to Interactive (TTI) metric.
Clicking this audit reveals which main-thread tasks ran for longer than 50 ms.
How to avoid long main-thread tasks
This audit lists all the long tasks that are running on the main-thread. Ensure that you incorporate good practices into your development workflow to minimize the main-thread work in the interest of web performance.
Note: This is an expert-level optimization
Only experienced developers are advised to improve this audit.