Find Used CSS to Remove Unused CSS

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.

  1. Open the HTML source in Sublime Text
  2. Click Edit > Tag > Get CSS Classes (this copies the used CSS classes to the clipboard)
  3. Paste the used CSS classes in a new file and sort alphabetically
  4. Go through each CSS definition and remove the ones not in the list of used CSS classes