部署之前,有没有工具来压缩HTML类属性和CSS选择器? [英] Before deployment, is there tool to compress HTML class attribute and CSS selectors?

查看:121
本文介绍了部署之前,有没有工具来压缩HTML类属性和CSS选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在当前的项目中,我被要求在部署之前压缩HTML class属性和相应的CSS选择器
例如,生产代码

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

<div class="foo">
  <div id="bar"></div>
</div>

.foo {/*Style goes here*/}
#bar {/*Style goes here*/}

在部署上,我希望替换HTML类和相应的CSS选择器:

On deployment, I want the HTML class and corresponding CSS selectors to be substituted:

<div class="a">
  <div id="b"></div>
</div>

.a {/*Style goes here*/}
#b {/*Style goes here*/}

那里有什么可用的工具来压缩这种压缩?

What's the available tools there to archive this compression?

推荐答案

真的想要重命名类名称(记住Madmartigan所说的) Google Closure Stylesheets 就是这样做的。这是一个矫枉过正的情况,YUI压缩机或其他任何缩小+ gzip应该能够提供足够的性能提升,但它可以实现。您必须使用其他Closure工具对您的.js文件和html模板进行适当的更改。

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

这篇关于部署之前,有没有工具来压缩HTML类属性和CSS选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆