Before deployment, is there tool to compress HTML class attribute and CSS selectors?

If you really want to rename class names (keeping in mind what Madmartigan said) Google Closure Stylesheets does that. It's an overkill, and YUI Compressor or any other minification + gzipping tool should give you enough performance boost, but it can do it. You'll have to use other Closure tools to make appropriate changes to your .js files and html templates.


There is also a project called "rename-css-selectors" if you handle the code with node:

https://www.npmjs.com/package/rename-css-selectors

There are plugins for nearly every build tool (webpack, parcel, gulp, ...):

https://github.com/JPeer264/node-rcs-core#plugins

This will minify all CSS selectors in HTML, JS and CSS files (actually any file you want). I saved 20ish% of the CSS filesize at the end.


This is amazingly short-sighted.

  • Step 1: Turn on GZip or Zlib compression in web server
  • Step 2: All text gets compressed, often by 70% or more
  • Step 3: There is no step 3.
  • Step 4: PROFIT