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

前端 未结 7 2186
暗喜
暗喜 2020-12-24 10:53

In current project, I was asked for compressing the HTML class attribute and corresponding CSS selectors before deployment. For example, the code on

7条回答
  •  星月不相逢
    2020-12-24 11:43

    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.

提交回复
热议问题