HTML minification is handled as follows. First, an HTML 5 (which really means
the WHATWG HTML living standard)
parser constructs a DOM as specified by the standard. Next, semantically
meaningless inter-element whitespace
are removed from the DOM and semantically meaningfull runs of whitespace are
compressed to single spaces, except in
Finally, the DOM is serialized, compressing
where possible and omitting optional start and end
Unlike some other HTML minifiers, Squoosh uses neither Java nor regular expressions to parse HTML.
Squoosh will not minify
Add this line to your application's Gemfile:
And then execute:
$ bundle install
Or install it yourself as:
$ gem install squoosh
The three basic minification functions are
significantly speed up minifying HTML with repeated scripts and style sheets.
Using with Jekyll
_plugins/squoosh.rb file with the contents
require 'squoosh' Jekyll::Hooks.register [:documents, :pages], :post_render, priority: :high do |doc| case File.extname(doc.destination('./')) when '.html', '.htm' doc.output = Squoosh::minify_html doc.output when '.js' doc.output = Squoosh::minify_js doc.output end end
CSS minification could be handled similarly, or
foo.css files could simply
be renamed to
sass: style: compressed
Bug reports and pull requests are welcome on GitHub at https://github.com/stevecheckoway/squoosh.
The gem is available as open source under the terms of the MIT License.