Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

Optionally remove whitespace after vulcanization of css #2025

Closed samccone closed 5 years ago

samccone commented 8 years ago

As the vulcanize process inlines the JS and CSS for elements, the resulting elements.vulcanized.html contains several hundred KB of empty space. By using gulp-minify-inline on the vulcanized file, the size goes from 447K down to around 267K for the default install. Even with gzipped calls, this can be quite a bit of pageload reduced.

ref: https://github.com/PolymerElements/polymer-starter-kit/pull/486#issue-115633232 https://github.com/PolymerElements/polymer-starter-kit/issues/564 https://github.com/PolymerElements/polymer-starter-kit/pull/565 https://github.com/Polymer/vulcanize/issues/283

justinfagnani commented 8 years ago

It's going to be fun figuring out the right places for these issues :)

polybuild might be the right place for this one, assuming it sticks around. Of course, it may be easier to collect all the command line related things here and deprecate all the other command line interfaces.

justinfagnani commented 8 years ago

Blocked on #5

TimvdLippe commented 8 years ago

I have had a good experience with https://github.com/kangax/html-minifier Seemed to be working with Polymer, using the following configuration:

htmlmin({
  collapseWhitespace: true,
  removeComments: true,
  removeAttributeQuotes: true,
  removeRedundantAttributes: true,
  useShortDoctype: true,
  removeEmptyAttributes: true,
  removeScriptTypeAttributes: true,
  removeStyleLinkTypeAttributes: true,
  removeOptionalTags: true
})

(see https://github.com/AreaFiftyLAN/lancie-frontend/blob/master/gulpfile.js#L107-L117)

justinfagnani commented 8 years ago

Thanks for the info @TimvdLippe! We'll be adding minification very soon.