什么是最好的 JavaScript 压缩/混淆工具?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6948690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the best JavaScript compression/obfuscation tool?
提问by Goro
What kind of a tool would you recommend for JavaScript compression and/or obfuscation? A google search comes back with a lot of online tools, but I am not sure how to gauge their effectiveness/usefulness.
您会推荐哪种工具用于 JavaScript 压缩和/或混淆?谷歌搜索返回了许多在线工具,但我不确定如何衡量它们的有效性/实用性。
Is there a tool that you would recommend for this?
有没有你会推荐的工具?
Thanks,
谢谢,
采纳答案by aepheus
Closure Complier: http://code.google.com/closure/compiler/
关闭编译器:http: //code.google.com/closure/compiler/
YUI Compressor: http://developer.yahoo.com/yui/compressor/
YUI 压缩器:http: //developer.yahoo.com/yui/compressor/
Come to mind. You'll want to take them for a spin with your own code, as a lot of factors come into play with minifying. Basically, see which one makes the smallest file (and verify that your code works as it should).
浮现在脑海中。你会想用你自己的代码试一试,因为很多因素都会影响到缩小。基本上,看看哪个文件最小(并验证您的代码是否按预期工作)。
回答by rmribeiro
There are many tools that transform Javascript in something different. I currently classify these tools in the following objectives:
有许多工具可以以不同的方式转换 Javascript。我目前将这些工具分为以下目标:
- Minify: make the code smaller by removing comments, renaming variables...
- Compress: Compress using non destructive compression of javascript
- Optimize: Make the code run faster (ex: Closure)
- Obfuscate: Protect the code
- 缩小:使代码被删除注释,重命名变量小...
- 压缩:使用 javascript 的非破坏性压缩进行压缩
- 优化:使代码运行得更快(例如:Closure)
- 混淆:保护代码
My order has some meaning behind it. Because generally the higher level includes all be features below.
我的命令背后有一些意义。因为一般较高的层次包括以下所有的特征。
So a good Javascript Obfuscator is able to minify, compress, optimize...
所以一个好的 Javascript Obfuscator 能够缩小、压缩、优化......
Many tools do some of these levels well individually. They can be combined making them more effective but my experience has shown that combining several such tools make it a nightmare to try and pin point a problem.
许多工具单独完成其中一些级别。它们可以结合起来使它们更有效,但我的经验表明,结合几个这样的工具会使尝试查明问题成为一场噩梦。
My suggestion for a good overall Javascript obfuscator would be to use jscrambler.com
我对一个好的整体 Javascript 混淆器的建议是使用jscrambler.com
For optimization and minification google closure (has sugested by aepheus) is a excellent solution.
对于优化和缩小谷歌关闭(已被 aepheus 推荐)是一个很好的解决方案。
回答by Jakob
UglifyJS: https://github.com/mishoo/UglifyJS
UglifyJS:https: //github.com/mishoo/UglifyJS
The page contains a comparison with other minifiers if you scroll down a bit. One of the most notable parts is this:
如果您向下滚动一点,该页面包含与其他缩小器的比较。最值得注意的部分之一是:
UglifyJS is the fastest to run. On my laptop UglifyJS takes 1.35s for DynarchLIB, while YUI takes 2.7s and GCL takes 6.5s.
UglifyJS 是运行最快的。在我的笔记本电脑上,DynarchLIB 的 UglifyJS 需要 1.35 秒,而 YUI 需要 2.7 秒,GCL 需要 6.5 秒。
It written in JavaScript, so no need for separate runtimes etc. It plays nicely with both node.js and npm.
它是用 JavaScript 编写的,因此不需要单独的运行时等。它可以很好地与 node.js 和 npm 配合使用。
回答by Deepak Patil
you can also try http://openwaf-js-mini.appspot.com,slightly better than YUI Compressor
你也可以试试http://openwaf-js-mini.appspot.com,比 YUI Compressor 稍微好一点