yui/yuicompressor: YUI Compressor https://github.com/yui/yuicompressor 
 
YUI Compressor 详细介绍

YUI Compressor 是一个用来压缩 JS 和 CSS 文件的工具,采用Java开发。

使用方法:

//压缩JS
java -jar yuicompressor-2.4.2.jar --type js --charset utf-8 -v src.js > packed.js
//压缩CSS
java -jar yuicompressor-2.4.2.jar --type css --charset utf-8 -v src.css > packed.css

 
YUI Compressor uses a modified version of the Rhino library (http://www.mozilla.org/rhino/) The changes were made to support JScript conditional comments, preserved comments, unescaped slash characters in regular expressions, and to allow for the optimization of escaped quotes in string literals
 
 
YUI Compressor http://yui.github.io/yuicompressor/
 

How does the YUI Compressor work?

The YUI Compressor is written in Java (requires Java >= 1.4) and relies on Rhino to tokenize the source JavaScript file. It starts by analyzing the source JavaScript file to understand how it is structured. It then prints out the token stream, omitting as many white space characters as possible, and replacing all local symbols by a 1 (or 2, or 3) letter symbol wherever such a substitution is appropriate (in the face of evil features such as eval or with, the YUI Compressor takes a defensive approach by not obfuscating any of the scopes containing the evil statement) The CSS compression algorithm uses a set of finely tuned regular expressions to compress the source CSS file. The YUI Compressor is open-source, so don't hesitate to look at the code to understand exactly how it works.

Using the YUI Compressor from the command line

  1. $ java -jar yuicompressor-x.y.z.jar
  2. Usage: java -jar yuicompressor-x.y.z.jar [options] [input file]
  3.  
  4. Global Options
  5. -h, --help Displays this information
  6. --type <js|css> Specifies the type of the input file
  7. --charset <charset> Read the input file using <charset>
  8. --line-break <column> Insert a line break after the specified column number
  9. -v, --verbose Display informational messages and warnings
  10. -o <file> Place the output into <file> or a file pattern.
  11. Defaults to stdout.
  12.  
  13. JavaScript Options
  14. --nomunge Minify only, do not obfuscate
  15. --preserve-semi Preserve all semicolons
  16. --disable-optimizations Disable all micro optimizations
  17.  
  18. GLOBAL OPTIONS
  19.  
  20. -h, --help
  21. Prints help on how to use the YUI Compressor
  22.  
  23. --line-break
  24. Some source control tools don't like files containing lines longer than,
  25. say 8000 characters. The linebreak option is used in that case to split
  26. long lines after a specific column. It can also be used to make the code
  27. more readable, easier to debug (especially with the MS Script Debugger)
  28. Specify 0 to get a line break after each semi-colon in JavaScript, and
  29. after each rule in CSS.
  30.  
  31. --type js|css
  32. The type of compressor (JavaScript or CSS) is chosen based on the
  33. extension of the input file name (.js or .css) This option is required
  34. if no input file has been specified. Otherwise, this option is only
  35. required if the input file extension is neither 'js' nor 'css'.
  36.  
  37. --charset character-set
  38. If a supported character set is specified, the YUI Compressor will use it
  39. to read the input file. Otherwise, it will assume that the platform's
  40. default character set is being used. The output file is encoded using
  41. the same character set.
  42.  
  43. -o outfile
  44.  
  45. Place output in file outfile. If not specified, the YUI Compressor will
  46. default to the standard output, which you can redirect to a file.
  47. Supports a filter syntax for expressing the output pattern when there are
  48. multiple input files. ex:
  49. java -jar yuicompressor.jar -o '.css$:-min.css' *.css
  50. ... will minify all .css files and save them as -min.css
  51.  
  52. -v, --verbose
  53. Display informational messages and warnings.
  54.  
  55. JAVASCRIPT ONLY OPTIONS
  56.  
  57. --nomunge
  58. Minify only. Do not obfuscate local symbols.
  59.  
  60. --preserve-semi
  61. Preserve unnecessary semicolons (such as right before a '}') This option
  62. is useful when compressed code has to be run through JSLint (which is the
  63. case of YUI for example)
  64.  
  65. --disable-optimizations
  66. Disable all the built-in micro optimizations.
  67.  
 

yuicompressor的更多相关文章

  1. Ant 执行 YUICompressor

    Ant 执行 YUICompressor 任务压缩 JavaScript 和 CSS 文件,解决中文乱码问题,增加源文件字符编码集设定 标签: javascriptantcss任务encodingnu ...

  2. jdk、apache-ant结合yuicompressor配置的CSS与JS合并压缩工具

    前序:网上很多css与js合并打包工具,其中最流行的就是ant结合yui-compressor,鉴于学习与工作需要今天就学习了一下这种方式,供大家学习交流. 步骤:1.安装jdk,并配置其变量环境:有 ...

  3. 一款js、css压缩工具yuicompressor

    //压缩JS java -jar yuicompressor-.jar --type js --charset utf- -v src.js > packed.js //压缩CSS java - ...

  4. 完整的yuicompressor单个压缩和批量压缩以及gzip再次压缩,拦截器的配置等

    下载地址:http://yuilibrary.com/download/yuicompressor/ 个人认为现在yuicompressor是最安全,最值得信赖的压缩工具,至少到现在没出现过问题 1. ...

  5. webstorm使用YUIcompressor压缩js css并指定目录

    YUI插件下载地址: https://github.com/yui/yuicompressor/releases 配置教程: 注意:这里用 ..\ 代表上级目录, '\' 千万别写成 '/'

  6. YUICompressor的安装及使用(一)

    step1:下载ant和YUICompressor    1) Ant:   http://ant.apache.org/bindownload.cgi   打开页面后,下拉滚动条,找到如下图所示,单 ...

  7. 亲身实践 yui-compressor压缩js和css

    最近很懒散,个人感情.家庭原因,没有动力去学东西,老是发誓要搞好前端工程化,老中断,唉!没有魄力! 最近老觉得这前端工程化有什么好的,东西那么多,还得学!直到前几天产品提了个优化,说搜索结果页跳商品详 ...

  8. Spring Mvc + Maven + yuicompressor 使用 profile 来压缩 javascript ,css 文件; (十)

    profile相关知识点: 在开发项目时,设想有以下场景: 你的Maven项目存放在一个远程代码库中(比如github),该项目需要访问数据库,你有两台电脑,一台是Linux,一台是Mac OS X, ...

  9. YUI-compressor 在Linux下安装和使用

    介绍一个非常流行的javascript压缩工具YUI compressor,可以提供更好的压缩效率:该工具由著名的Yahoo Exceptional Performance项目组出品. JSMin非常 ...

  10. javascript/css压缩工具---yuicompressor使用方法

    1. 下载 地址:https://github.com/yui/yuicompressor/downloads 2. 安装 yuicompressor是由java写成的一组jar文件,需要jdk环境支 ...

随机推荐

  1. TStringList,快速解析 查找测试。。。很有用,再也不用 FOR 循环了

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABKAAAALHCAIAAAA2Gq0zAAAgAElEQVR4nOydeVgUV76wK5OZb5JJZi

  2. win10下Vmware12虚拟机安装Ubuntu16.04

    一.下载VMware虚拟机: VMware12下载地址:点这里 VMware 12pro 专业版永久许可证密钥:  5A02H-AU243-TZJ49-GTC7K-3C61N 如果许可证不能用,参考这 ...

  3. 湖南集训day2

    难度:☆☆ /*显然可以前缀和*/ #include<iostream> #include<cstdio> #include<cstring> #define N ...

  4. HDU 1045 Fire Net 状压暴力

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1045 Fire Net Time Limit: 2000/1000 MS (Java/Others)  ...

  5. 【APIO2016】Gap

    题目描述 有 $N$ 个严格递增的非负整数 $a_1, a_2, \dots, a_N$($0 \leq a_1 < a_2 < \cdots < a_N \leq 10^{18}$ ...

  6. CF997D

    分析: 假设在第一个树上我们有一个长度为x的环,在第二树上我们有一个长度为y的环,那么可以在叉积树上构造出$\binom{x+y}{x}$个长度为x+y的环 问题的关键就变成了如何统计出在一个树上的长 ...

  7. js转换金额为中文大写

    function changeMoneyToChinese(money){ var cnNums = new Array("零","壹","贰&quo ...

  8. Engine中如何进行七参数投影转换?

    来自:http://zhihu.esrichina.com.cn/?/question/6858 解决办法]:首先创建自定义geotransformation,然后用IGeometry.Project ...

  9. 【面试 IO】【第十一篇】 java IO

    1.什么是比特(Bit),什么是字节(Byte),什么是字符(Char),它们长度是多少,各有什么区别 1>Bit最小的二进制单位 ,是计算机的操作部分 取值0或者1 2>Byte是计算机 ...

  10. 【转载】Spark学习——入门

    要学习分布式以及数据分析.机器学习之类的,觉得可以通过一些实际的编码项目入手.最近Spark很火,也有不少招聘需要Spark,而且与传统的Hadoop相比,Spark貌似有一些优势.所以就以Spark ...