Ticket #2246 (closed New Feature: wontfix)

Opened 7 years ago

Last modified 12 months ago

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 || CKEDITOR.tools.trim( param ) == '' )


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

... it would end up like this:

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

    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

comment:1 Changed 6 years ago by fredck

  • Milestone changed from CKEditor 3.0 to CKEditor 3.x

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

comment:2 Changed 5 years ago by fredck

  • Milestone CKEditor 3.x deleted

Milestone CKEditor 3.x deleted

comment:3 Changed 12 months ago by Reinmar

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

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