|
1 ============================================================================== |
|
2 YUI Compressor |
|
3 ============================================================================== |
|
4 |
|
5 NAME |
|
6 |
|
7 YUI Compressor - The Yahoo! JavaScript and CSS Compressor |
|
8 |
|
9 SYNOPSIS |
|
10 |
|
11 Usage: java -jar yuicompressor-x.y.z.jar [options] [input file] |
|
12 |
|
13 Global Options |
|
14 -h, --help Displays this information |
|
15 --type <js|css> Specifies the type of the input file |
|
16 --charset <charset> Read the input file using <charset> |
|
17 --line-break <column> Insert a line break after the specified column number |
|
18 -v, --verbose Display informational messages and warnings |
|
19 -o <file> Place the output into <file>. Defaults to stdout. |
|
20 |
|
21 JavaScript Options |
|
22 --nomunge Minify only, do not obfuscate |
|
23 --preserve-semi Preserve all semicolons |
|
24 --disable-optimizations Disable all micro optimizations |
|
25 |
|
26 DESCRIPTION |
|
27 |
|
28 The YUI Compressor is a JavaScript compressor which, in addition to removing |
|
29 comments and white-spaces, obfuscates local variables using the smallest |
|
30 possible variable name. This obfuscation is safe, even when using constructs |
|
31 such as 'eval' or 'with' (although the compression is not optimal is those |
|
32 cases) Compared to jsmin, the average savings is around 20%. |
|
33 |
|
34 The YUI Compressor is also able to safely compress CSS files. The decision |
|
35 on which compressor is being used is made on the file extension (js or css) |
|
36 |
|
37 GLOBAL OPTIONS |
|
38 |
|
39 -h, --help |
|
40 Prints help on how to use the YUI Compressor |
|
41 |
|
42 --line-break |
|
43 Some source control tools don't like files containing lines longer than, |
|
44 say 8000 characters. The linebreak option is used in that case to split |
|
45 long lines after a specific column. It can also be used to make the code |
|
46 more readable, easier to debug (especially with the MS Script Debugger) |
|
47 Specify 0 to get a line break after each semi-colon in JavaScript, and |
|
48 after each rule in CSS. |
|
49 |
|
50 --type js|css |
|
51 The type of compressor (JavaScript or CSS) is chosen based on the |
|
52 extension of the input file name (.js or .css) This option is required |
|
53 if no input file has been specified. Otherwise, this option is only |
|
54 required if the input file extension is neither 'js' nor 'css'. |
|
55 |
|
56 --charset character-set |
|
57 If a supported character set is specified, the YUI Compressor will use it |
|
58 to read the input file. Otherwise, it will assume that the platform's |
|
59 default character set is being used. The output file is encoded using |
|
60 the same character set. |
|
61 |
|
62 -o outfile |
|
63 Place output in file outfile. If not specified, the YUI Compressor will |
|
64 default to the standard output, which you can redirect to a file. |
|
65 |
|
66 -v, --verbose |
|
67 Display informational messages and warnings. |
|
68 |
|
69 JAVASCRIPT ONLY OPTIONS |
|
70 |
|
71 --nomunge |
|
72 Minify only. Do not obfuscate local symbols. |
|
73 |
|
74 --preserve-semi |
|
75 Preserve unnecessary semicolons (such as right before a '}') This option |
|
76 is useful when compressed code has to be run through JSLint (which is the |
|
77 case of YUI for example) |
|
78 |
|
79 --disable-optimizations |
|
80 Disable all the built-in micro optimizations. |
|
81 |
|
82 NOTES |
|
83 |
|
84 + If no input file is specified, it defaults to stdin. |
|
85 |
|
86 + The YUI Compressor requires Java version >= 1.4. |
|
87 |
|
88 + It is possible to prevent a local variable, nested function or function |
|
89 argument from being obfuscated by using "hints". A hint is a string that |
|
90 is located at the very beginning of a function body like so: |
|
91 |
|
92 function fn (arg1, arg2, arg3) { |
|
93 "arg2:nomunge, localVar:nomunge, nestedFn:nomunge"; |
|
94 |
|
95 ... |
|
96 var localVar; |
|
97 ... |
|
98 |
|
99 function nestedFn () { |
|
100 .... |
|
101 } |
|
102 |
|
103 ... |
|
104 } |
|
105 |
|
106 The hint itself disappears from the compressed file. |
|
107 |
|
108 + C-style comments starting with /*! are preserved. This is useful with |
|
109 comments containing copyright/license information. For example: |
|
110 |
|
111 /*! |
|
112 * TERMS OF USE - EASING EQUATIONS |
|
113 * Open source under the BSD License. |
|
114 * Copyright 2001 Robert Penner All rights reserved. |
|
115 */ |
|
116 |
|
117 becomes: |
|
118 |
|
119 /* |
|
120 * TERMS OF USE - EASING EQUATIONS |
|
121 * Open source under the BSD License. |
|
122 * Copyright 2001 Robert Penner All rights reserved. |
|
123 */ |
|
124 |
|
125 AUTHOR |
|
126 |
|
127 The YUI Compressor was written and is maintained by: |
|
128 Julien Lecomte <jlecomte@yahoo-inc.com> |
|
129 The CSS portion is a port of Isaac Schlueter's cssmin utility. |
|
130 |
|
131 COPYRIGHT |
|
132 |
|
133 Copyright (c) 2007-2009, Yahoo! Inc. All rights reserved. |
|
134 |
|
135 LICENSE |
|
136 |
|
137 All code specific to YUI Compressor is issued under a BSD license. |
|
138 YUI Compressor extends and implements code from Mozilla's Rhino project. |
|
139 Rhino is issued under the Mozilla Public License (MPL), and MPL applies |
|
140 to the Rhino source and binaries that are distributed with YUI Compressor. |