Which Javascript minifier (cruncher) does the same things that the one Google uses for its JS APIs?

徘徊边缘 提交于 2019-12-17 21:44:57

问题


I am a Google Maps API (javascript) developer. I have noticed that Google uses a Javascript minifier that has the following features:

  1. Shortens variables, properties, arguments, classes, function and method names, obfuscating the code. (eg. function1 -> a, function2 -> b, function3 -> c)
  2. 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.
  3. 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 in the whole internet a Javascript minifier with those features. Anyone knows one?


回答1:


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.




回答2:


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.




回答3:


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




回答4:


There's also a .NET port of YUI Compressor which allows you to:-

  • intergrate the minification/file combining into Visual Studio post-build events
  • intergrate into a TFS Build (including CI)
  • if you wish to just use the dll's in your own code (eg. on the fly minification).



回答5:


A simple online javascript minifier based on dojo's shrink safe can be found at http://netspurt.com




回答6:


What you are describing is 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.



来源:https://stackoverflow.com/questions/489847/which-javascript-minifier-cruncher-does-the-same-things-that-the-one-google-us

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!