Reduce Unused CSS

CSS: Another Render-blocking Resource

Just like reducing unused JavaScript, reducing unused CSS files is another basic optimization that you should be regularly reviewing. Unnecessary CSS, like JavaScript, can cause render-blocking behavior to occur, which will delay when the other aspects of your page, like First Paint, will occur. Additionally, style sheets rules that are not being used for critical, above-the-fold content do nothing but affect performance and the user perceived load time. This is especially true for external style sheets since these extra network trips just increase the time until content can start being displayed on the page.

How to Reduce Unused CSS

Before a page can render the actual styles on a page, the browser must download, parse, and execute the files. If there is any unused CSS, this is just inefficient, as the browser will naturally take longer to process a larger file. Within Lighthouse reports, if there are any stylesheets identified that can save more than 2kB or more, they will be listed with their size and their potential size. You will want to review the style sheets and decide on what rules are critical versus non-critical versus no longer necessary. For style sheets that are critical, using inlining CSS directly into HTML is a great method to utilize to help reduce the number of files and to render these resources as soon as possible. Another option, which we discussed earlier in this guide about JavaScript, is code splitting. This entails splitting your critical and non-critical CSS, so the critical CSS is processed and rendered first. The non-critical CSS is processed later.

lighthouse

Lighthouse

Lighthouse is an open-source tool that is used to run an audit against your web pages and provides scores and suggestions for improving page performance, accessibility, SEO, and more.

pagespeed

PageSpeed Terms

PageSpeed Insights is a tool created by Google that reports on the performance of a page on both mobile and desktop devices, and provides suggestions on how that page may be improved.

yslow

YSlow

YSlow is an open-source website analysis tool that can be used to identify web page performance issues. Learn more about the YSlow to enhance your web pages and the user experience.