When building websites, it’s inevitable that you’ll end up with a bunch of unused CSS as you make changes to the site. To remove unused CSS, you can use Sublime Text’s Get CSS Classes function to first find used CSS. Then, remove all CSS definitions that aren’t in that list.
- Open the HTML source in Sublime Text
- Click Edit > Tag > Get CSS Classes (this copies the used CSS classes to the clipboard)
- Paste the used CSS classes in a new file and sort alphabetically
- Go through each CSS definition and remove the ones not in the list of used CSS classes