Yc右键一键压缩Js文件

总是要把js文件压缩~~有了这个便轻松了~~~

准备
压缩 JS 使用的是 YUI Compressor,需要 Java 运行环境支持,因此需要先安装 Java 运行环境。
下载 YUI Compressor:
http://yuilibrary.com/downloads/download.php?file=2a526a9aedfe2affceed1e1c3f9c0579
下载后解压,把 yuicompressor-2.4.2.jar 移动到某个目录,如:E:\soft\yuicompressor-2.4.2.jar。

运行以下命令测试 YUI Compressor 是否正常,正常应输出如下:

C:\> java -jar E:\soft\yuicompressor-2.4.2.jar

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

Global Options
-h, –help Displays this information
–type Specifies the type of the input file
–charset Read the input file using
–line-break
Insert a line break after the specified column number
-v, –verbose Display informational messages and warnings
-o Place the output into . Defaults to stdout.

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:\\soft\\yuicompressor-2.4.2.jar –charset UTF-8 \”%1\” -o \”%1\”"

 

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

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

 

转自http://hily.me/blog/2010/12/add-yui-compressor-to-context-menu/

你可能感兴趣的:(JavaScript,PHP,windows,css,yui)