Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uglifyjs compresseses but does not mangle function or variable names

I found a post back in 2012 that has similar problems, but it invokes uglifyjs differently

Uglify-js doesn't mangle variable names

I have a Windows 7 environment, uglifyjs 2 installed via npm and post How to install node modules globally?

I call uglify as follows:

uglifyjs --compress dead_code=true --mangle --mangle-toplevel -- x.js > x-min.js

My code crunches (from 127kb to 55kb) but when I open my code, I find function and variable names are original.

The browser demo tool gives the same results.

Anyone care to advise how I can obfusicate variable and function names with, or without uglify ?


1 Answers

You're mentioning using UglifyJS2.

The option --mangle-toplevel or -mt comes from UglifyJS.

There is no --mangle-toplevel option in UglifyJS2.

In UglifyJS2, to enable the mangler, you need to pass the --mangle or -m option. It accepts the following (comma-separated) options:

  • toplevel
  • eval

So, in your case, you'll need to use --mangle toplevel.

like image 79
HiDeo Avatar answered May 04 '26 17:05

HiDeo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!