Skip to content
This repository

Ruby gem for compressing html

branch: master
Octocat-spinner-32 lib Fix bug #6 June 04, 2013
Octocat-spinner-32 profile speed-up September 27, 2012
Octocat-spinner-32 spec Fix #5 March 29, 2013
Octocat-spinner-32 .gitignore add profile script September 27, 2012
Octocat-spinner-32 .travis.yml replace rainpress with css_press April 28, 2012
Octocat-spinner-32 Gemfile use ruby-prof only for mri September 27, 2012
Octocat-spinner-32 LICENSE.txt v0.0.8 multi_css, add license November 28, 2012
Octocat-spinner-32 Rakefile replace rainpress with css_press April 28, 2012
Octocat-spinner-32 Readme.md update readme March 29, 2013
Octocat-spinner-32 html_press.gemspec Fix bug #6 June 04, 2013
Readme.md

HtmlPress Gem VersionBuild Status Dependency Status Code Climate

How it works

Remove all whitespace junk. Leave only HTML

1.               ┌――――――――――――――――――╖        2.         ┌――――――――――――――――――╖
  ●――――――――――――――├―╢ <html> ws junk ║          ●――――――――├―――――――――╢ <html> ║
                 └――――――――――――――――――╜                   └――――――――――――――――――╜

Usage

Ruby

require 'html_press'
compressed_html = HtmlPress.press html

Jekyll

see jekyll_press

Rails

TODO :exclamation:

Sinatra

TODO :exclamation:

Command line

TODO :exclamation:

TODO

  • use parser () instead of regexp's
    • add option to convert relative urls to absolute urls (for SEO)
  • ambigious ampersands for compression?
  • Support other js/css minifiers (Closure, YUI compressor)
  • htmlTydi
  • Rack plugin
  • add script to benchmark real projects like amazon or stackoverflow
  • support html5 tags
  • add more options
  • Optimization: make substring replace based on substring length and its position in initial string

Alternatives

Additional tools

  • jeanny - rename css classes and ids in css and html files
    • make shorter pathes for images in css
  • deadweight - remove unused css rules from css files
  • csscss will parse any CSS files you give it and let you know which rulesets have duplicated declarations.
  • css-spriter, sprite-factory - combine images in sprites
  • resize images by size defined in html and vice versa embed size of images in html
  • #1, #2 - inline small images in css
  • smusher, jpegtran, optipng - losslessly minify images
  • sprockets, jammit - asset bundlers
  • w3c_validators
  • reduce

Resources

Minimize HTML

Front-end optimization

Something went wrong with that request. Please try again.