YUI compressor: what is microoptimization?

YUI Compressor in its (not very extensive) documentation points this out as an option:

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

Does anyone know what that means?
What does it turn on / off?
I did not find documentation about this.

Thanks!

+3
source share
1 answer

Looking at the source of JavaScriptCompressor:

lines 548 -

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

lines 467 -

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

lines 497 -

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

Therefore, it converts the use of constant strings to foo['bar']in foo.barand {'bar':x}in {bar:x}.

+10
source

Source: https://habr.com/ru/post/1705204/


All Articles