The Opportunities section of your Lighthouse report lists all stylesheets with unused CSS with a potential savings of 2 KBs or more. Remove the unused CSS to reduce unnecessary bytes consumed by network activity:
How unused CSS slows down performance
<link> tag is a common way to add styles to a page:
<link href="main.css" rel="stylesheet">
main.css file that the browser downloads is known as an external stylesheet,
because it's stored separately from the HTML that uses it.
By default, a browser must download, parse, and process all external stylesheets that it encounters before it can display, or render, any content to a user's screen. It wouldn't make sense for a browser to attempt to display content before the stylesheets have been processed, because the stylesheets may contain rules that affect the styling of the page.
Each external stylesheet must be downloaded from the network. These extra network trips can significantly increase the time that users must wait before they see any content on their screens.
Unused CSS also slows down a browser's construction of the render tree. The render tree is like the DOM tree, except that it also includes the styles for each node. To construct the render tree, a browser must walk the entire DOM tree, and check which CSS rules apply to each node. The more unused CSS there is, the more time that a browser might potentially need to spend calculating the styles for each node.
How to detect unused CSS
The Coverage tab of Chrome DevTools can help you discover critical and uncritical CSS. See View used and unused CSS with the Coverage tab.
You can also extract this information from Puppeteer. See page.coverage.
Inline critical CSS & defer non-critical CSS
Similar to inlining code in a
inline critical styles required for the first paint
<style> block at the
head of the HTML page.
Then load the rest of the styles asynchronously using the
Consider automating the process of extracting and inlining "Above the Fold" CSS using the Critical tool.
Learn more in Defer non-critical CSS.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.