前言:
此刻你们对“jsuglify”大体比较重视,小伙伴们都需要分析一些“jsuglify”的相关文章。那么小编也在网络上搜集了一些有关“jsuglify””的相关文章,希望你们能喜欢,大家快快来学习一下吧!What are the differences between UglifyJS and JShaman?
UglifyJS is primarily used for compressing JS code and reducing its size. JShaman, on the other hand, is specifically designed for obfuscating and encrypting JS code, with the aim of making it unreadable, obfuscating functional logic, and encrypting hidden data or characters in the code. It is used for code protection.
Therefore, they are completely different. It is just that UglifyJS also has some obfuscation capabilities, which often leads people to mistakenly believe that it is also an obfuscation and encryption tool.
To demonstrate the difference between the two with an example: Example, file name: example.js, code:
var x = { baz_: 0, foo_: 1, calc: function() { return this.foo_ + this.baz_; }};x.bar_ = 2;x["baz_"] = 3;console.log(x.calc());
Using UglifyJS for compression, command:
uglifyjs example.js -c -m --mangle-props
-c enables compression
-m enables obfuscation
The result will be:
var x={o:0,_:1,l:function(){return this._+this.o}};x.t=2,x.o=3,console.log(x.l());
As you can see, UglifyJS removes line breaks, and changes long variable names to short ones, achieving compression without affecting code readability. The functional logic remains clear.
Using JShaman for obfuscation and encryption will result in unreadable and chaotic code.
Of course, whether using UglifyJS for compression and obfuscation, or using JShaman for obfuscation and encryption, it will not affect the normal use of the code.
标签: #jsuglify