我是一名 Google 地图 API (JavaScript) 开发人员。 我注意到 Google 使用 JavaScript minifier 具有以下功能:
- 缩短变量、属性、参数、类、函数和方法名称,混淆代码(例如,function1 → a、function2 → b 和 function3 → c)
- 某些变量、类、属性和方法可以标记为不被处理,因此其名称与 API 手册中记录的保持相同。
- 它会在 API 的每个颠覆中重新运行,就像构建任务一样,我注意到由于经过处理的名称从一个版本更改为另一个版本。
我在整个互联网上还没有找到具有这些功能的 JavaScript 压缩器。 有吗?
I am a Google Maps API (JavaScript) developer. I have noticed that Google uses a JavaScript minifier that has the following features:
- Shortens variables, properties, arguments, classes, function and method names, obfuscating the code (e.g., function1 → a, function2 → b, and function3 → c)
- Some variables, classes, properties and methods can be marked to not be crunched, so its name remains the same as documented in the API manual.
- It is rerun in each subversion of the API, like a build task, I noticed that because of the crunched names changes from one version to another.
I have not found a JavaScript minifier in the whole Internet with those features. Is there one?
发布评论
评论(6)
Google 现在已经开放了他们使用的压缩器,以及其他一些内部 JavaScript 功能。
这些内容均以“Closure Tools” 和于本月初宣布。
Google has now opened up the minifier they use, along with some other internal JavaScript goodies.
It's all under the name "Closure Tools" and was announced earlier this month.
以下是我所知道的缩小器:
Dean Edwards 的打包器; YUI 压缩器; JSMIN; 和 Dojo 压缩器
除了这些之外,GWT 编译器 在从 Java 文件生成高效的 JavaScript 文件方面做了很多工作。 如果他们就是这么用的,我不会感到惊讶。
Here are the minifiers I know of:
Dean Edwards' packer; YUI Compressor; JSMIN; and Dojo compressor
In addition to these, the GWT compiler does quite a bit to make efficient JavaScript files out of Java files. It wouldn't surprise me if that is what they use.
还有YUI Compressor 的 .NET 端口,它允许您:
There's also a .NET port of YUI Compressor which allows you to:
我相信 YUICompressor 执行 #1(函数名称除外)和 #2 使用在压缩期间删除的特殊语法。
#3 只是一个构建任务,而不是压缩器的功能。
YUICompressor(旧)
YUICompressor(新)
I believe that YUICompressor does #1, except for the function names, and #2 using a special syntax that is removed during compression.
#3 is just a build task, not a function of the compressor.
YUICompressor (old)
YUICompressor (new)
可以在 http://netspurt.com。
A simple online JavaScript minifier based on Dojo's shrink safe can be found at http://netspurt.com.
您描述的是“混淆器”,而不是缩小器,通过搜索“JavaScript 混淆器”可以轻松找到它们。
我们的 SD Thicket ECMAScript Obfuscator 同时进行混淆和缩小。
You are describing an "obfuscator", not a minifier, and they are easily found by searching for "JavaScript obfuscator".
Our SD Thicket ECMAScript Obfuscator both obfuscates and minifies at the same time.