在整个 ASP.NET 应用程序中将 CSS 定义打乱为人类无法读取的状态的最佳方法
我不确定除了通过删除长词名称节省流量之外是否还会带来任何好处,但我肯定想隐藏我的命名、声明及其组织系统。
问题是,手动查找和替换将花费很长时间,并且每个细微的修改都可能需要部分或全部重做该过程。
有人想过这个问题吗? 也许写一个宏? 它是否足够智能,能够发现 CSS 文件中的名称? 有没有更好、更简单的东西存在?
I'm not sure if it will bring anything beyond saving on traffic through the removal of long-worded names, but I would definitely want to hide my system of namings, declarations and their organization.
The thing is that manual Find&Replace is going to take a very long time, and each slight modification could probably require the process to be redone in part or in whole.
Has anyone thought of this problem? Maybe write a macros? Will it be intelligent enough to be able to discover names in a CSS file? Does anything better and simplier exist?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
首先,我认为我根本不会这样做,通过降低可读性到底能得到什么?
但如果必须这样做,为什么不制作一个自定义解析器,将您的“开发”名称转换为“生产”名称,反之亦然?
Firstly I don't think I would do it at all, what exatly is to be gained by making it less readable?
But if one had to do it, why not make a custom parser that would convert your "development" names to "production" names and vice versa as needed?
使用 Perl。 简单的 Perl 脚本 可以递归搜索所有文件并用其他内容替换您指定的内容。
Use Perl. A simple perl script can search through all of your files recursively and replace whatever you specify with something else.
使用 CSS 压缩器。 这会让它变得非常难以阅读,但不可能让它完全不可读。 这是来自 CSS Drive 的一个。
Use a CSS compressor. It will make it really hard to read, but it's not possible to make it completely unreadable. Here's one from CSS Drive.
正如其他人所说,您可以使名称更短或意义更小,但要达到人类不可读的状态基本上是不可能的。
无论您如何重命名或扭曲 css,它仍然必须具有适当的属性,并且 html 必须引用命名的类和/或 id。
另外,像 firebug 这样的工具会准确无误地将用户指向正在使用的 css,我认为这会违背您的意图。
它还违背了在 html 中使用语义上有意义的标签的目的。
As others have stated, you can make the names shorter or less meaningful, but to reach a human-unreadable state is essentially not possible.
No matter how you rename or distort the css, it still has to have proper atributes and the html has to reference the named classes and/or ids.
Additionally tools like firebug will unfailingly point users to the css being used which I assume will defeat your intent.
It also defeats the purpose of using semantically meaningful tags in your html.
您不能使其“不可读”,但您可以通过使用 CSS 优化器 等内容来节省一些空间
You can't make it "unreadable", but you can save some space by using things like the CSS optimizer
您可能想尝试 YUI 压缩机:
http://developer.yahoo.com/yui/compressor/< /a>
You might want to try YUI Compressor:
http://developer.yahoo.com/yui/compressor/