Opened 9 years ago

Closed 3 years ago

#2246 closed New Feature (wontfix)

Create local short named aliases to global references

Reported by: fredck 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 8 years ago by fredck

  • Milestone changed from CKEditor 3.0 to CKEditor 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 7 years ago by fredck

  • Milestone CKEditor 3.x deleted

Milestone CKEditor 3.x deleted

comment:3 Changed 3 years ago by Reinmar

  • Resolution set to wontfix
  • Status changed from confirmed to closed

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 – 2017 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy