Opened 15 years ago

Closed 9 years ago

#2246 closed New Feature (wontfix)

Create local short named aliases to global references

Reported by: Frederico Caldeira Knabben Owned by:
Priority: Normal Milestone:
Component: Project : CKPackager Version:
Keywords: Cc:


The packager should be able to scan a function for all global references made inside of it. A global reference is a name not declared inside the function scope with the "var" or "function" statements.

For example, suppose we have the following function:

function( param )
    if ( CKEDITOR.env.IE || param ) == '' )


    if ( CKEDITOR.env.IE )
        alert( CKEDITOR );
    return CKEDITOR.doAgain() );

... it would end up like this:

function( A )
    var B = CKEDITOR;
    var C = B.env.IE,
        D =;

    if ( C || D( A ) == '' )


    if ( C )
        alert( B );
    return D( B.doAgain() );

Note that the code is smart enough to reuse the new names when creating other var names too.

Change History (3)

comment:1 Changed 14 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 3.0CKEditor 3.x

Ok... my original example of changing to "D" is wrong (as it looses the object scope), but the idea is still valid.

comment:2 Changed 13 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 3.x

Milestone CKEditor 3.x deleted

comment:3 Changed 9 years ago by Piotrek Koszuliński

Resolution: wontfix
Status: confirmedclosed

Since we use a 3rd party code minifier there's no place for such improvements any more. We have to rely on the library we use.

Moreover, I did a test once and replaced most of longer tokens in the minified code with their short aliases. It allowed me to save <3% in minified code and <1% in gzipped. And in real life results would be worse, e.g. because of contexts preserving.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy