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/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值