minor fixes to README.md
This commit is contained in:
23
README.md
23
README.md
@@ -224,7 +224,7 @@ separate step, different from variable name mangling. Pass
|
|||||||
`--mangle-props`. It will mangle all properties that are seen in some
|
`--mangle-props`. It will mangle all properties that are seen in some
|
||||||
object literal, or that are assigned to. For example:
|
object literal, or that are assigned to. For example:
|
||||||
|
|
||||||
```js
|
```javascript
|
||||||
var x = {
|
var x = {
|
||||||
foo: 1
|
foo: 1
|
||||||
};
|
};
|
||||||
@@ -255,10 +255,10 @@ mangled to the same name in all of them. For this, pass `--name-cache filename.
|
|||||||
and UglifyJS will maintain these mappings in a file which can then be reused.
|
and UglifyJS will maintain these mappings in a file which can then be reused.
|
||||||
It should be initially empty. Example:
|
It should be initially empty. Example:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
rm -f /tmp/cache.json # start fresh
|
$ rm -f /tmp/cache.json # start fresh
|
||||||
uglifyjs file1.js file2.js --mangle-props --name-cache /tmp/cache.json -o part1.js
|
$ uglifyjs file1.js file2.js --mangle-props --name-cache /tmp/cache.json -o part1.js
|
||||||
uglifyjs file3.js file4.js --mangle-props --name-cache /tmp/cache.json -o part2.js
|
$ uglifyjs file3.js file4.js --mangle-props --name-cache /tmp/cache.json -o part2.js
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, `part1.js` and `part2.js` will be consistent with each other in terms
|
Now, `part1.js` and `part2.js` will be consistent with each other in terms
|
||||||
@@ -273,7 +273,7 @@ Using quoted property name (`o["foo"]`) reserves the property name (`foo`)
|
|||||||
so that it is not mangled throughout the entire script even when used in an
|
so that it is not mangled throughout the entire script even when used in an
|
||||||
unquoted style (`o.foo`). Example:
|
unquoted style (`o.foo`). Example:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ echo 'var o={"foo":1, bar:3}; o.foo += o.bar; console.log(o.foo);' | uglifyjs --mangle-props keep_quoted -mc
|
$ echo 'var o={"foo":1, bar:3}; o.foo += o.bar; console.log(o.foo);' | uglifyjs --mangle-props keep_quoted -mc
|
||||||
var o={foo:1,a:3};o.foo+=o.a,console.log(o.foo);
|
var o={foo:1,a:3};o.foo+=o.a,console.log(o.foo);
|
||||||
```
|
```
|
||||||
@@ -350,7 +350,7 @@ console.log(result.code);
|
|||||||
|
|
||||||
## Minify option structure
|
## Minify option structure
|
||||||
|
|
||||||
```
|
```javascript
|
||||||
{
|
{
|
||||||
warnings: false,
|
warnings: false,
|
||||||
parse: {
|
parse: {
|
||||||
@@ -577,8 +577,7 @@ Examples:
|
|||||||
```javascript
|
```javascript
|
||||||
// test.js
|
// test.js
|
||||||
var globalVar;
|
var globalVar;
|
||||||
function funcName(firstLongName, anotherLongName)
|
function funcName(firstLongName, anotherLongName) {
|
||||||
{
|
|
||||||
var myVariable = firstLongName + anotherLongName;
|
var myVariable = firstLongName + anotherLongName;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -737,7 +736,7 @@ using `var` with `reduce_vars` (enabled by default) should suffice.
|
|||||||
You can also use conditional compilation via the programmatic API. With the difference that the
|
You can also use conditional compilation via the programmatic API. With the difference that the
|
||||||
property name is `global_defs` and is a compressor property:
|
property name is `global_defs` and is a compressor property:
|
||||||
|
|
||||||
```js
|
```javascript
|
||||||
var result = uglifyJS.minify(fs.readFileSync("input.js", "utf8"), {
|
var result = uglifyJS.minify(fs.readFileSync("input.js", "utf8"), {
|
||||||
compress: {
|
compress: {
|
||||||
dead_code: true,
|
dead_code: true,
|
||||||
@@ -749,7 +748,7 @@ var result = uglifyJS.minify(fs.readFileSync("input.js", "utf8"), {
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Using native Uglify AST with `minify()`
|
### Using native Uglify AST with `minify()`
|
||||||
```
|
```javascript
|
||||||
// example: parse only, produce native Uglify AST
|
// example: parse only, produce native Uglify AST
|
||||||
|
|
||||||
var result = UglifyJS.minify(code, {
|
var result = UglifyJS.minify(code, {
|
||||||
@@ -764,7 +763,7 @@ var result = UglifyJS.minify(code, {
|
|||||||
|
|
||||||
// result.ast contains native Uglify AST
|
// result.ast contains native Uglify AST
|
||||||
```
|
```
|
||||||
```
|
```javascript
|
||||||
// example: accept native Uglify AST input and then compress and mangle
|
// example: accept native Uglify AST input and then compress and mangle
|
||||||
// to produce both code and native AST.
|
// to produce both code and native AST.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user