The html_mini gem includes a simple module and a middleware that adds HTML minification for Rack applications. HtmlMini is optimised for speed over syntax preservation.
This is an early release that has not been tested in production. I wanted to try out creating a rack middleware and a gem. The minify logic is minimal therefore unexpected issues can occur. Use at your own risk
Using with Rack application
HtmlMini can be used with any Rack application, for example with a Sinatra application. If your application includes a rackup file or uses Rack::Builder to construct the application pipeline, simply require and use as follows:
require 'rack/minify' use Rack::Minify run app
Using with Rails 3
In order to use, include the following in a Rails application Gemfile file:
require 'rack/minify' config.middleware.insert_before Rack::ETag, Rack::Minify
Check the Rack configuration:
- rack-htmltidy: An Outdated Tidy Rack middleware
- railscast.com: A screencast on middleware (a bit old)
HtmlMini is copyright 2012 Jerome Touffe-Blin and contributors. It is licensed under the BSD license. See the include LICENSE file for details.