The main thread also processes user events. So, any time the main thread is busy doing something else, your web page may not respond to user interactions, leading to a bad experience.
How the Lighthouse main thread work audit fails
Lighthouse flags pages that keep the main thread busy for longer than 4 seconds during load:
To help you identify the sources of main thread load, Lighthouse shows a breakdown of where CPU time was spent while the browser loaded your page.
How to minimize main thread work
The sections below are organized based on the categories that Lighthouse reports. See The anatomy of a frame for an overview of how Chromium renders web pages.
See Do less main thread work to learn how to use Chrome DevTools to investigate exactly what your main thread is doing as the page loads.
Style and layout
- Reduce the scope and complexity of style calculations
- Avoid large, complex layouts and layout thrashing
- Stick to compositor only properties and manage layer count
- Simplify paint complexity and reduce paint areas