kakra / html_cleanup

Home | Edit | New

Home

html_cleanup aims at minifying HTML code implemented as a Rails after_filter. Minifying is done by using bundled versions of jsmin.rb and cssmin.rb from Ryan Grove. Nokogiri is used to walk the document tree and reducing inlined CSS and JS, removing redundant white space in text elements, and selected attributes. This is currently not very elaborated, you should use caching to achieve better performance and the HTML minifyer may have bugs. But after all this is GitHub, so you are free to fork and I would be happy to add your fixups to my code base.

To get started install this as a Rails plugin and add an “after_filter HtmlCleanupFilter” to your application controller.

Todo

  • Do not run in developer mode (or make this ultimately configurable)
  • Figure out how to use Nokogiri to reduce whitespace to work around potential problems with the current algorithm
Last edited by kakra, Sun Feb 22 08:19:20 -0800 2009
Home | Edit | New
Versions: