类似于Javascript的Minifying和Obsfucating CSS [英] Minifying and Obsfucating CSS similar to Javascript

查看:183
本文介绍了类似于Javascript的Minifying和Obsfucating CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有几个工具,有能够混淆的JavaScript文件,如通过将一个简单的功能,如:

I know there are several tools out there that are capable of obfuscating JavaScript files such as by turning a simple functions like:

function testing()
{
  var testing;
  var testing2;
  alert(testing+testing2);
}



into

function a(var a,b;alert(a+b);)

我的问题是这样的东西是用于CSS / HTML(或有一个工具,具有类似的效果)?特别是,实际上重命名变量和refereneces和缩小/混淆工具消除了额外的空格等。

My question is does something like this exist for use with CSS/HTML (or is there a tool that has a similar effect)? In particular, a minification/obfuscation tool that actually renames variables and refereneces and eliminates additional white-space etc.

如果是的话 - 会在性能上的好处超过了可读性这两个CSS / HTML / JavaScript的缩小/混淆?

And if so - would the benefits in performance outweigh the readability in both CSS/HTML/JavaScript minification/obfuscation?

推荐答案

这是缩小非常困难的HTML或CSS,因为所有能安全地保存是空白(这不意味着巨大的节省)。至于类重命名,你松开了一个重要的部分,它有语义代码(代表意义)。我认为最好的选择是确保您的Web服务器上启用了gzip压缩,并且尽可能将资源合并到一个文件中。

It is very difficult to 'minify' HTML or CSS because all that can safely be saved is white space (which doesn't amount to a huge saving). As for class renaming, you loose an important part of the web which is having semantic code (which represents meaning). I think the best option is to ensure that you have gzip compression enabled on your web server and focus on combining your assets into a single file wherever possible.

这篇关于类似于Javascript的Minifying和Obsfucating CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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