Insight & Insanity

web development with a dash of life

HTML Compress and Replace for Sublime Text

In my last write-up regarding CodeKit’s Kit Language I mentioned a plug-in (package) for Sublime Text (aka ST) that I had created. Well here it is. A simple plugin/package that will compress any HTML file using the Build System option.

What It Is

The Kit Language will generate static HTML files for you upon save, but what about compression? Well, CodeKit doesn’t provide HTML compression. So you are left using a separate app, or a plugin that resides within the Tools → Build System menu in Sublime Text. But the only plugins I could find for ST generated a renamed file or a file in another folder. But in this scenario, working with the Kit language, a duplicate HTML file is unnecessary, and wastes time. I didn’t want to waste this time, each time a change needs made, to delete the CodeKit compiled HTML files and rename the compressed versions output by ST. So born was the extremely simplistic HTML Compress and Replace.


Until HTML Compress and Replace is available using Package Control, you can download it directly from the link below or from the repo on GitHub.

  1. In ST, go to Preferences → Browse Packages and take note of the location of this folder.
  2. Place the HTML Compress and Replace folder in this directory. (You may need to restart ST for it to be available.)
  3. In ST, go to Tools → Build System and click on HTML Compress and Replace.
  4. While viewing an HTML file, press F7.
  5. The window at the bottom of ST will tell you when the build is finished.
  6. Wait for the view to refresh or simply click on another tab or file and then click back to view the compressed HTML.

View HTML Compress and Replace on GitHub
Inspiration for this came from darkdelphin.