Closed trevordmiller closed 10 years ago
I was actually looking into this yesterday. The htmlmin task is super buggy (the collapse whitespace flag can and will delete your whole file). What I found was that compressing a really really big vulcanized file (think the entire Polymer element set) only produced ~1kb in savings. And it seems like it does a pretty sketchy job of compressing things (read: inconsistent) so I may actually remove it from the build entirely.
@robdodson Gotcha. That makes sense. I didn't realize that minifying your HTML had so little savings!
Neither did I. I'm going to test it a few more times but a larger concern for me is if htmlmin starts breaking a vulcanized file or causing hard to debug issues for people. That it already produces really inconsistent output leads me to think that it could be a pain down the line. On Jul 25, 2014 9:44 AM, "Trevor D. Miller" notifications@github.com wrote:
@robdodson https://github.com/robdodson Gotcha. That makes sense. I didn't realize that minifying your HTML had so little savings!
— Reply to this email directly or view it on GitHub https://github.com/yeoman/generator-polymer/issues/53#issuecomment-50174379 .
After playing with this some more it looks like htmlmin actually does produce significantly smaller output, however it seems to be blowing up on lines like this:
<div id="mainContainer" flex?="{{mode !== 'cover'}}" on-scroll="{{scroll}}">
vulcanize (by way of cheerio) is encoding the apostrophes in those lines and that breaks htmlmin
<div id="mainContainer" flex?="{{mode !== 'cover'}}" on-scroll="{{scroll}}">
Related issue: https://github.com/cheeriojs/cheerio/issues/319
I'll try to fold it back in when I can get the cheerio issues sored
You might want to try out https://github.com/sindresorhus/grunt-minify-html, it uses Minimize which uses an actual HTML parser.
@robdodson Also, if you go the Gulp route, the Web Starter Kit uses "gulp-minify-html"...https://www.npmjs.org/package/gulp-minify-html
I dropped htmlmin in favor of minifyHTML
The
htmlmin
task in the Gruntfile.js only producesexpanded
html by default, which is essentially not minified. I would imagine that this was a mistake and that thehtmlmin
task should be set toexpand: false
and the options that have been commented out should be added back in?