YUI Compressor 使用

最近项目需求,要压缩js,文件就学习了YUI Compressor。

下载:http://yuilibrary.com/downloads/#yuicompressor。 最新的是2.4.6。前提是要安装jdk,就不废话了。

下载下来后解压。找到 yuicompressor-2.4.6\build\yuicompressor-2.4.6.jar

这个就是要运行的jar.

打开cmd.输入(我要压缩的文件放到了e盘符根目录。)

C:\Documents and Settings\Administrator>java -jar E:\yuicompressor-2.4.6\yuicomp
ressor-2.4.6\build\yuicompressor-2.4.6.jar  --preserve-semi   -o  E:\outputfile.js     E:\inputfile.js

 

好了,在e盘目录下就生成了一个压缩好的文件。参数详见下面。

 

-----------------------------------------------------------------------------------------

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' *.c
s
                            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'.

------------------------------------------------------------------------------------------

语法: java -jar yuicompressor-x.y.z.jar [options] [input file] 通用参数:
    -h, --help                 显示帮助信息
   --type <js|css>            指定输入文件的文件类型
   --charset <charset>        指定读取输入文件使用的编码
   --line-break <column>      在指定的列后插入一个 line-bread 符
   -v, --verbose              显示info和warn级别的信息
   -o <file>                  指定输出文件。默认输出是控制台。

JavaScript专用参数:
     --nomunge                  只压缩, 不对局部变量进行混淆。
   --preserve-semi            保留所有的分号。
   --disable-optimizations    禁止优化。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值