Reputation:
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 ?
Upvotes: 3
Views: 4972
Reputation: 10563
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:
So, in your case, you'll need to use --mangle toplevel
.
Upvotes: 12