2

I was considering using a ruby gem to compress my HTML, but we're already serving gzipped files, and I was wondering if there is any reduction in served file size by doing both HTML compression and GZIP, or if that's totally pointless.

3

Your files will be smaller if you minify them before using gzip.

  • Gzip isn't perfect compression. It doesn't remove remove all the redundancy that minifying does.
  • Gzip is lossless compression. At the very least that means it has to preserve information such as the number of indentations on each line. It may only take a byte or two for preserving that info, but if you don't remove that noise, it still is "info" to gzip.

To test this I concatenated 95 JavaScript files from one of my projects. I minified them using yui-compressor and zipped both the minified and unminified versions. The un-minified version is 27% larger compared to the minified version after gzip has been applied to both.

Unminified

  • 130K - mega.js
  • 33K - mega.js.gz

Minified

  • 90K - mega.min.js
  • 26K - mega.min.js.gz
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.