Opened 17 years ago
Closed 11 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: |
Description
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 ) == '' ) CKEDITOR.doStuff(); CKEDITOR.doOtherStuff(); 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 ) == '' ) B.doStuff(); B.doOtherStuff(); 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 16 years ago by
Milestone: | CKEditor 3.0 → CKEditor 3.x |
---|
comment:3 Changed 11 years ago by
Resolution: | → wontfix |
---|---|
Status: | confirmed → 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.
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.