admin管理员组

文章数量:1289632

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 --press 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 ?

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 --press 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 ?

Share Improve this question edited May 23, 2017 at 12:32 CommunityBot 11 silver badge asked Jul 30, 2016 at 16:04 user4278933user4278933 2
  • 2 What about function arguments and internal variables? Are they minimized? Uglifying public functions and variable names typically cause problems when accessing from other scripts or html. You can find some alternitives on the uglify website lisperator/uglifyjs. I got really good results using jspacker which may also be an alternative: dean.edwards.name/packer – Wolfgang Commented Jul 30, 2016 at 16:21
  • this seams to be relevant for top-level names: stackoverflow./questions/10959154/… – Wolfgang Commented Jul 30, 2016 at 16:28
Add a ment  | 

1 Answer 1

Reset to default 12

You're mentioning using UglifyJS2.

The option --mangle-toplevel or -mt es 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 (ma-separated) options:

  • toplevel
  • eval

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

本文标签: javascriptuglifyjs compresseses but does not mangle function or variable namesStack Overflow