Features Videos Help About Updates
Menu Buy Now

HTML-Minifier

First Steps:
Getting Started
Live-Reload Browsers
Browser Sync
Set Language Options
Set Output Paths & Action
Second Steps:
Defaults For New Projects
Build Your Project
Set Target Browsers
Stuff To Know:
CodeKit + Git
Troubleshooting
License Recovery
PostCSS Tools:
Autoprefixer
PurgeCSS
Custom PostCSS Plugins
Other Tools:
npm
Babel — (JS Transpiler)
Terser — (JS Minifier)
Rollup — (JS Bundler)
Cache-Buster
HTML-Minifier
LightningCSS
Bless
Languages:
Sass
Less
Stylus
JavaScript
CoffeeScript
TypeScript
Pug
Haml
Slim
Kit
Markdown
JSON
Image Optimizers:
WebP
PNG
JPEG
SVG
GIF
Frameworks:
CodeKit Frameworks
Tailwind
Bootstrap
Bourbon
Bitters
Zurb Foundation
Susy
Nib
Jeet
Syntax Checkers:
ESLint
Advanced:
Hooks
Environment Variables
Adding Custom Languages
Team Workflows
Scripting CodeKit
Editor Plugins:
Nova
Atom
Sublime Text
Coda 2
More
Read-Only Mode
Upgrading From 2.0
FAQ

Why Minify HTML?

The biggest reason is to strip comments from an HTML file before deploying it.

Stripping comments and extra whitespace from a file can also reduce its size, which means faster page loads—especially on cellular networks.

CodeKit uses HTML-Minifier to shrink HTML files.


Enabling HTML-Minifier

a screenshot of the HTML-minifier checkbox in the file inspector pane in CodeKit

Select an HTML file (or any type that compiles to HTML, such as Kit or Pug). Click the "Minify Compiled HTML" popup button, then choose either "always" or one of the build environment options.

All Files At Once

You can enable the minifier for all files of a given type at once by opening Project Settings and choosing a language.

Warning: Valid Syntax Required

The minifier will fail to run on files that are not HTML or that have syntax errors. In these cases, it may also produce invalid or incorrect output. If that happens, check your original file for syntax issues.

Note: You can use HTML-Minifier on files that are not strict HTML (Kit, Pug, Slim, Markdown, etc.) because CodeKit will first compile the file to HTML and then run the minifier.


Minifier Options

Currently, no options are exposed for HTML-Minifier. It will strip comments, delete insignificant whitespace, and remove duplicate/unneeded attributes.

Tip: to keep a comment, use !:

<!--! YOU SHALL NOT PASS -->

The reason more configuration options are not exposed is that they tend to break your HTML. With the defaults, you get all the biggest optimizations without any risk of broken files.


Made in San Diego, CA

Follow the Developer on Twitter

Email Support

Report a Bug

Privacy Policy