混淆javascript属性? [英] Obfuscate javascript properties?

查看:130
本文介绍了混淆javascript属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近测试了 UglifyJS YUI压缩器并注意到一些奇怪的东西。

两个缩小器似乎都没有改变对象属性的名称,只改变变量和函数的名称。

I've recently tested UglifyJS and YUI Compressor and noticed something odd.
Both minifiers don't seem to change the names of object properties, only the names of variables and functions.

例如,如果我有以下代码:

for instance if I have the following code:

var objName = {first:2, second:4};
alert(objName.first + " " + objName.second);

名称第一个 second 在缩小版本中保持不变。

为什么会这样?

the names first and second remain unchanged in the minified version.
Why is that?

推荐答案

这是因为它不知道对象的使用位置。它可以在其他代码的外部使用,你不希望你的其他代码在你混淆时不得不改变。

It's because it doesn't know where the object is going to be used. It could be used externally by other code and you wouldn't want your other code to have to change whenever you obfuscate it.

编辑所以基本上,这就是为了防止模糊处理破坏对混淆时可能无法弄清楚的属性的外部/内部引用。

Edit So basically, it's like that to prevent obfuscation from breaking external/internal references to properties that may not be possible to figure out while obfuscating.

这篇关于混淆javascript属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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