Once your website starts to grow, so will your code. As your code expands, CSS may suddenly become hard to maintain, and you may end up overwriting one CSS rule with another. This complicates things and you will probably end up with plenty of bugs.
If this is happening to you, it’s time for you to audit your site’s CSS. Auditing your CSS will allow you to identify portions of your CSS that is not optimized. You can also reduce the stylesheet filesize by eliminating lines of code that is slowing down your site’s performance.
Recommended Reading: Why CSS Could Be The Hardest Language Of All
Here are 5 good tools to help you audit and optimize CSS.
Type-o-matic is a Firebug plugin to analyze fonts that are being used in a website. This plugin gives a visual report in a table, bearing font properties such as the font family, the size, weight, color, and also the number of times the font is used in the web page. Through the report table, you can easily optimize the font use, remove what is unnecessary, or combine styles that are way too similar.
CSS Lint is a linting tool that analyzes the CSS syntax based on specific parameters that address for performance, accessibility, and compatibility of your CSS. You would be surprised with the results, expect a lot of warnings in your CSS. However, these errors will eventually help you fix the CSS syntax, and make it more efficient. Additionally, you will also be a better CSS writer.
CSS ColorGuard is a relatively new tool. It’s built as a Node module and it runs across all platforms: Windows, OS X, and Linux. CSS ColorGuard is a command line tool that will notify you if you are using similar colors in your stylesheet; e.g.
#f3f3f3 is pretty close to
#f4f4f4, so you might want to consider merging the two. CSS ColorGuard is configurable, you can set the similarity threshold as well as set the colors you want the tool to ignore.
CSS Dig is a Python script and works locally on your computer. CSS Dig will run a thorough examination in your CSS. It will read and combine properties e.g. all background color declarations will go underneath the background section. That way you can easily make decisions based on the report when trying to standardize your CSS syntax e.g. you may find color across styles with the following color declaration.
color: #ccc; color: #cccccc; color: #CCC; color: #CCCCCC;
These color declarations do the same thing. You might as well go with the
#ccc or with the capital
#CCC as the standard. CSS Dig can expose this redundancy for other CSS properties too, and you will be able to make your code be more consistent.