javascript-obfuscator icon indicating copy to clipboard operation
javascript-obfuscator copied to clipboard

Reduce Obfuscated Code Size

Open anywhichway opened this issue 5 years ago • 8 comments

Is your feature request related to a problem? Please describe.

Everyone likes smaller code!

This suggestion is base don the assumption that the functions I see scattered throughout the obfuscated code are "dead code noise", e.g. function(g,a){return g*a;}.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

There are a lot of functions and they take up more space that necessary.

Describe the solution you'd like

Replace function(g,a){return ga;} and similar with with (g,a) => ga; Or perhaps randomly vary between the two.

Should perhaps be a config option, e.g. "Arrow obfuscation OK";

Describe alternatives you've considered

None

Additional context Add any other context or screenshots about the feature request here.

anywhichway avatar Dec 03 '20 21:12 anywhichway

How about implement like here? If arrow functions are present in code - obfuscator also will use them.

da411d avatar Dec 04 '20 20:12 da411d

Not sure how this addresses my comment, unless you are saying that obfuscator mirrors the function style of the code it is flattening or dead ending when defining other functions.

In this case, I should work to use more arrow functions in my source and less regular functions.

On Fri, Dec 4, 2020 at 12:26 PM Manzhula David [email protected] wrote:

How about this https://github.com/javascript-obfuscator/javascript-obfuscator#kind-of-variables ? If arrow functions are present in code - obfuscator also will use them.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/javascript-obfuscator/javascript-obfuscator/issues/830#issuecomment-739000962, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF2US2DP2O2GPPFC7ZK743STFAVPANCNFSM4UMRKJSQ .

anywhichway avatar Dec 04 '20 22:12 anywhichway

@anywhichway, no no, I just offered idea for this feature. Sory if I confused you

da411d avatar Dec 05 '20 08:12 da411d

Hmm. Some mechanism that detects if obfuscated code uses arrow functions and after that appends them - would be nice. Anyway if I do this feature it will transform only functions appended by the obfuscator itself.

sanex3339 avatar Dec 05 '20 13:12 sanex3339

exactly what I was looking for!

On Saturday, December 5, 2020, Timofey Kachalov [email protected] wrote:

Hmm. Some mechanism that detects if obfuscated code uses arrow functions and after that appends them - would be nice. Anyway if I do this feature it will transform only functions appended by the obfuscator itself.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/javascript-obfuscator/javascript-obfuscator/issues/830#issuecomment-739250520, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABF2US3PP7C2UDDZQCNZVJDSTIXZ7ANCNFSM4UMRKJSQ .

anywhichway avatar Dec 05 '20 19:12 anywhichway

If you use this somewhere in code arrow function can just destoy all. I mean:

function kruzya() {const self = this;this.gay = true; return self;} // work fine
const kruzya = () => this.gay = true, this; // unexpected this

Or if I miss what exact mean author of this issue :thinking:

BlackYuzia avatar Dec 08 '20 21:12 BlackYuzia

@BlackYuzia, as stated in this comment, it will transform only functions appended by the obfuscator itself.

da411d avatar Dec 08 '20 21:12 da411d

Other idea: add option kinda "supportModernJavascrypt". It will be useful for destructuring like in #720 and also may be useful for future interesting syntax constructions

da411d avatar Jan 04 '21 18:01 da411d