[转]好用的命令行工具

各有优缺点,混搭着用。同时,也可以编进Ant里。

压缩:

YUICompressor
支持JS和CSS
下载:http://yuilibrary.com/downloads/#yuicompressor
文档:http://developer.yahoo.com/yui/compressor/
快速上手:
java -jar yuicompressor-x.y.z.jar myfile.js -o myfile-min.js –charset utf-8

Closure  Compiler
不支持CSS文件压缩
下载:compiler.jar
文档:http://code.google.com/closure/compiler/docs/overview.html
要求:JRE 1.6
快速上手:
java -jar compiler.jar –js myfile.js –js_output_file myfile-min.js
相关介绍:http://hikejun.com/blog/?p=476
支持多个文件合并:
java -jar compiler.jar –js myfile-1.js –js myfile-2.js –js_output_file myfile-min.js

合并:

Combiner
下载:http://github.com/nzakas/combiner/downloads
文档:http://www.nczonline.net/blog/2009/09/22/introducing-combiner-a-javascriptcss-concatenation-tool/
快速上手:
java -jar combiner-0.0.1.jar -v -o myfile.js *.js
java -jar combiner-0.0.1.jar -v -o myfile.js myfile-1.js myfile-2.js

图片无损优化:

Smusher
调用smush.it 或 punypng 接口。
文档:http://github.com/grosser/smusher
要求:ruby + rubygems
快速上手:
smusher imgs/*.*
smusher imgs/*.* –service PunyPng

Mac下安装:
第一次安装smusher失败,缺东西需要先装xcode(OS安装盘2上有),再装行了。
另注意punypng区分大小写 smusher macosxlogo.png –service PunyPng

dataURI:

CSSEmbed
CSS中的图片转成dataURI。(我不建议所有图片全部dataURI转换)
下载:http://github.com/nzakas/cssembed/downloads/
文档:http://www.nczonline.net/blog/2009/11/03/automatic-data-uri-embedding-in-css-files/
快速上手:
java -jar cssembed-x.y.z.jar -o styles_new.css styles.css

dataURI
本地或远程的图片转成dataURI。
下载:http://github.com/nzakas/datauri/downloads/
快速上手:
java -jar datauri-x.y.z.jar -o output.txt image.png

检查工具:

WARI
扫描js/css文件中的冗余,和没用的图片。试了一下没用的css和图片找的比较准,javascript绑定的方法都算没用不准。这东西最大的好处是整站的找 RT @umutm: Web Application Resource Inspector – WARI – http://wari.konem.net/
下载/文档:http://wari.konem.net/
要求:JRE 1.6
快速上手:java -jar ~/Library/wari/wari.jar 弹出一个图形化界面。其实这不算命令行工具,这工具还是有点用的

Rhino +  JSLint
Javascript/html代码品质检查工具。
介绍:http://www.JSLint.com/rhino/index.html
用法:java -jar rhino/js.jar rhino/fulljslint.js my_js_file.js

 

转自《Kejun's Blog》

转载于:https://www.cnblogs.com/sirius-cg/archive/2012/07/24/2606482.html

你可能感兴趣的:([转]好用的命令行工具)