You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.
How does that help compressors specifically? It looks like the resulting JS would be larger and more complicated, so I don't know how that would help the compressor. Is there a specific compressor that struggles with the way the code works now so I can take a look?
Google Closure Compiler, Yahoo Compressor and other good compressors can rename local variables and parameters (_$$System$Drawing$Bitmap$prototype) to something one-letter:
(function(){
...
var a = System.Drawing.Bitmap.prototype;
a._ctor$1 = function (x, b) {
a._ctor$0.call(this, x);
};
...
})();
So You can use long significant names for local variables (to maintain readability) BUT compiler will optimize it reducing javascript size a lot.
the best way is to make JSIL.MakeClass to return a function itselt so you can generate something like this
//Trick: using unassigned parameter instead local variable definition (,v instead var v will save some chars)
(function(_$$System$Drawing$Bitmap,_$$System$Drawing$Bitmap$prototype){
_$$System$Drawing$Bitmap$prototype=_$$System$Drawing$Bitmap.prototype;
// Class definition below
_$$System$Drawing$Bitmap$prototype._ctor$1 = function (filename, b) {
_$$System$Drawing$Bitmap$prototype._ctor$0.call(this, filename);
};
})(JSIL.MakeClass(.....));
var $prototype='prototype'; // must be LOCAL variable
obj[$prototype].foo=....;
obj[$prototype].bar=....;
obj[$prototype].aaa=...;
prepared after compilation (LOCAL variable names will be shortened to 1 char)
var p='prototype'; // must be LOCAL variable
obj[p].foo=....;
obj[p].bar=....;
obj[p].aaa=...;
this trick works great if you combine whole assembly definition into one anonimous function and apply this trick for wide-used "apply" "call" "prototype" etc
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Wrap class definitions into anonimous functions and use variables instead fully qualified
The text was updated successfully, but these errors were encountered: