YUICompressor : 有效压缩空格  整理变理 缩小代码体积

官方主页:http://yuilibrary.com/downloads/#yuicompressor

文档:http://developer.yahoo.com/yui/compressor

1.常规应用 :

YUICompressor 本身由java编写

运行格式:java -jar yuicompressor-x.y.z.jar yourfile.js -o yourfile-min.js –charset utf-8

2.将YUICompressor 加入到右键菜单中

在网上看到此方法,记录下:

下载YUICompressor 包  解压,将build 目录下的yuicompressor-2.4.7 copy 到某一个目录下 ,如E:\Software\yuicompressor-2.4.7.jar

测试jar 包是否能正常运行

打开 cmd  输入:java -jar E:\Software\yuicompressor-2.4.7.jar

出现以下信息:

Usage: java -jar yuicompressor-x.y.z.jar [options] [input file]

Global Options
  -h, --help                      Displays this information
  --type <js|css>                 Specifies the type of the input file
  --charset <charset>             Read the input file using <charset>
  --line-break <column>           Insert a line break after the specified column numbr
  -v, --verbose                   Display informational messages and warnings
  -o <file>                        Place the output into <file>. Defaults to stdout.
                                      Multiple files can be processed using the following syntax:
                                      java -jar yuicompressor.jar -o '.css$:-min.css' *.css
                                      java -jar yuicompressor.jar -o '.js$:-min.js' *.js
JavaScript Options
  --nomunge                   Minify only, do not obfuscate
  --preserve-semi            Preserve all semicolons
  --disable-optimizations   Disable all micro optimizations

If no input file is specified, it defaults to stdin. In this case, the 'type'
option is required. Otherwise, the 'type' option is required only if the input
file extension is neither 'js' nor 'css'.

通过修改注册表,在右键菜单上添加 "Compress JS using YUI Compressor“ 菜单项

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell]

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Compress JS using YUI Compressor]

[HKEY_CLASSES_ROOT\AllFilesystemObjects\shell\Compress JS using YUI Compressor\command]
@="java -jar E:\\Software\\yuicompressor-2.4.7.jar --charset UTF-8 \"%1\" -o \"%1\""

把以上内容复制下来,将 yuicompressor-2.4.7.jar 的路径改为你的存放路径,保存为 .reg 文件后双击该文件,即可将这些项目导入注册表。

导入完成后,在任意一个文件或文件夹上点击右键,就可以看到我们添加的 “Compress JS using YUI Compressor” 菜单项了。

posted on 2012-06-27 16:16  justincai  阅读(615)  评论(0编辑  收藏  举报