From 030611b729af46d2239bd09c95f88e708660f254 Mon Sep 17 00:00:00 2001 From: iliashk Date: Sat, 25 Jun 2016 11:48:39 +0300 Subject: [PATCH] Add Node API documentation for mangling options --- README.md | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ab9de62..7262ef81 100644 --- a/README.md +++ b/README.md @@ -661,7 +661,8 @@ Other options: - `fromString` (default `false`) — if you pass `true` then you can pass JavaScript source code, rather than file names. -- `mangle` — pass `false` to skip mangling names. +- `mangle` (default `true`) — pass `false` to skip mangling names, or pass + an object to specify mangling options (see below). - `mangleProperties` (default `false`) — pass an object to specify custom mangle property options. @@ -680,6 +681,32 @@ Other options: - `except` - pass an array of identifiers that should be excluded from mangling + - `toplevel` — mangle names declared in the toplevel scope (disabled by + default). + + - `eval` — mangle names visible in scopes where eval or with are used + (disabled by default). + + Examples: + + ```javascript + //tst.js + var globalVar; + function funcName(firstLongName, anotherLongName) + { + var myVariable = firstLongName + anotherLongName; + } + + UglifyJS.minify("tst.js").code; + // 'function funcName(a,n){}var globalVar;' + + UglifyJS.minify("tst.js", { mangle: { except: ['firstLongName'] }}).code; + // 'function funcName(firstLongName,a){}var globalVar;' + + UglifyJS.minify("tst.js", { mangle: toplevel: true }}).code; + // 'function n(n,a){}var a;' + ``` + ##### mangleProperties options - `regex` — Pass a RegExp to only mangle certain names (maps to the `--mangle-regex` CLI arguments option) -- 2.34.1