JavaScript压缩 [英] JavaScript compression
问题描述
我寻找可以压缩JavaScript源代码的工具。我发现一些只删除空白字符的网络工具?但也许存在更好的工具,可以压缩用户的函数名称,字段名称,删除未使用的字段,其他。
通常用于压缩JS代码的工具是
$ b
- nomunge
仅限缩小。不要模糊局部符号。
它应该能够做你想要的。
这里是一篇关于它的文章:介绍YUI Compressor 。
引用该文章:
它从分析源代码
JavaScript文件开始,以了解它如何构造
。然后它打印出
令牌流,用1(或2或3)字母
符号替换所有本地
符号,只要这样的替换是
适当
作为sidenote:不要忘记gzip您的JS / CSS文件,当从您的网络服务器提供:
例如,如果您使用Apache,请查看 mod_deflate
。
I look for tool which can compress JavaScript source code. I found some web tools which only deletes whitespace chars? But maybe exist better tool which can compress user's function names, field name, deletes unused fields, others.
A tool often used to compress JS code is the YUI Compressor.
Considering there is this option :
--nomunge
Minify only. Do not obfuscate local symbols.
It should be able to do what you asked.
And here is an article about it : Introducing the YUI Compressor.
Quoting that article :
It starts by analyzing the source JavaScript file to understand how it is structured. It then prints out the token stream, replacing all local symbols by a 1 (or 2, or 3) letter symbol wherever such a substitution is appropriate
As a sidenote : don't forget to gzip your JS/CSS files, when serving them from your webserver : this will reduce the size of data that goes through the network quite a lot !
For instance, if you are using Apache, take a look at mod_deflate
.
这篇关于JavaScript压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!