views:

201

answers:

1

YUI Compressor, in its (not very extensive) documentation states this as an option:

--disable-optimizations
    Disable all the built-in micro optimizations.

Does anyone know what this means?
What will this turn on/off?
I haven't found any documentation about it.

Thanks!

+4  A: 

Looking at the source of JavaScriptCompressor:

lines 545-

    if (!disableOptimizations) {
        optimizeObjectMemberAccess(this.tokens);
        optimizeObjLitMemberDecl(this.tokens);
    }

lines 461 -

/*
* Transforms obj["foo"] into obj.foo whenever possible, saving 3 bytes.
*/
private static void optimizeObjectMemberAccess(ArrayList tokens) {

lines 491 -

/*
 * Transforms 'foo': ... into foo: ... whenever possible, saving 2 bytes.
 */
private static void optimizeObjLitMemberDecl(ArrayList tokens) {

So it's converting use of constant strings in foo['bar'] to foo.bar and {'bar':x} to {bar:x}.

Pete Kirkham
Thanks!I'm definitely disabling those. For some reason, they make me feel a bit weird about YUI doing that to my code.
Daniel Magliola