使用yuicompressorjs的压缩:

tar xf jdk-7u45-linux-i586.gz 

chmod 775  jdk1.7.0_45

mv jdk1.7.0_45 /usr/local/java

ln -s /usr/local/java/bin/java /usr/bin/

mv yuicompressor-2.4.8.jar /opt/

 

java -jar yuicompressor-x.y.z.jar --preserve-semi -o output.js input.js  

 

java -jar /usr/local/src/yuicompressor-2.4.8.jar -o ad.min.js ad.js  

 

参数说明:

-h, --help Displays this information  帮助信息
--type <js|css> Specifies the type of the input file  压缩类型
--charset <charset> Read the input file using <charset>   文件使用的字符集编码(如--charset utf-8
-v, --verbose Display informational messages and warnings   显示详细信息和警告信息
-o <file> Place the output into <file>. Defaults to stdout.      输出文件,默认为标准输出 

--preserve-semi Preserve all semicolons表示保留分号

 

使用packer2js的压缩:

packer2.perl 安装:

unzip  packer2.perl.zip  -d /opt/packer2

 

cd /opt/packer2/

perl jsPacker.pl -i input.js -o output.js -e62  


-e是混淆的程度 
[0=None 10=Numeric 62=Normal(alphanumeric) 95=High-ascii] 
一般使用62即可