Minifying and Obsfucating CSS similar to Javascrip

2019-01-18 06:06发布

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);)

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.

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

8条回答
劫难
2楼-- · 2019-01-18 06:30

If you use Ruby, here is a Ruby CSS Minifier that I use to good effect. Given my already-terse style, it gives me about 15% reduction in my file sizes.

For example, on one project the aggregate of 5 files at 32.3kiB becomes 1 file of 26.4kiB (18%). On another project, 2 files of 21.6kiB become 1 file of 19.0kiB (12%).

查看更多
The star\"
3楼-- · 2019-01-18 06:30

I have developed tool for Obfuscating CSS. It's target is not to make stylesheets load faster or whatever, but to make your "reusable" work safe from stealing. It has several methods how to make a hell of getting an original CSS source (But it's still in development and better methods will be used). I would reccomend it to HTML/CSS templates sellers, who provide live demos and are worried of thefts, and also for coders - freelancers, who wants to present their work to (untrusty) customers. You can try it: http://cssobfuscator.com

查看更多
登录 后发表回答