The safe optimizers remove whitespace and comments from code, but do not seek to actually change
naming inside of your source code. The aggressive optimizers go a step further and seek to crunch
variable and function names. While the aggressive optimizers achieve greater compression ratios, they
are not as safe to use in certain situations. For example, if you have eval() or with in your code (not
recommended anyway), these routines will be broken during the compression process. What ??™ s more,
some of the optimizers, such as Packer, use an eval - based approach to compress and uncompress.
However, there is a performance hit in the uncompression process and it could actually slow down your
script under certain conditions.
Here are some of the options available (ranked in order of conservatism employed in their algorithms):
JSMin (JavaScript Minifier; www.crockford.com/javascript/jsmin.html ) is perhaps the
best - known JavaScript optimizer. It is the most conservative of the optimizers, focusing on
simply removing whitespace and comments from JavaScript code.
YUI Compressor ( www.julienlecomte.net/blog/2007/08/13/introducing-theyui-
compressor ) is a recently introduced optimizer that claims to offer a happy medium
between the conservative JSMin and the more aggressive ShrinkSafe and Packer listed next.
Pages:
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246