Skip to main content

选项

解析选项

¥Parse options

  • bare_returns (默认值 false) --

支持顶层 return 语句

¥support top level return statements

  • html5_comments(默认 true

    ¥html5_comments (default true)

  • shebang (默认值 true) --

支持 #!command 作为第一行

¥support #!command as the first line

  • spidermonkey (默认值 false) --

接受 Spidermonkey (Mozilla) AST

¥accept a Spidermonkey (Mozilla) AST

压缩选项

¥Compress options

  • defaults (默认值: true) --

传递 false 以禁用大多数默认启用的 compress 转换。当你只想启用几个 compress 选项而禁用其余选项时很有用。

¥Pass false to disable most default enabled compress transforms. Useful when you only want to enable a few compress options while disabling the rest.

  • arrows (默认值: true) --

如果生成的代码较短,则转换的类和对象字面量方法也将转换为箭头表达式:m(){return x} 变成 m:()=>x。要对不使用 thisarguments 的常规 ES5 函数执行此操作,请参阅 unsafe_arrows

¥Class and object literal methods are converted will also be converted to arrow expressions if the resultant code is shorter: m(){return x} becomes m:()=>x. To do this to regular ES5 functions which don't use this or arguments, see unsafe_arrows.

  • arguments (默认值: false) --

尽可能将 arguments[index] 替换为函数参数名称。

¥replace arguments[index] with function parameter name whenever possible.

  • booleans (默认值: true) --

布尔上下文的各种优化,例如 !!a ? b : c → a ? b : c

¥various optimizations for boolean context, for example !!a ? b : c → a ? b : c

  • booleans_as_integers (默认值: false) --

将布尔值转换为 0 和 1,也使用 ==!= 而不是 ===!== 与布尔值进行比较。

¥Turn booleans into 0 and 1, also makes comparisons with booleans use == and != instead of === and !==.

  • collapse_vars (默认值: true) --

在副作用允许的情况下,折叠一次性使用的非常量变量。

¥Collapse single-use non-constant variables, side effects permitting.

  • comparisons (默认值: true) --

对二进制节点应用某些优化,例如 !(a <= b) → a > b(仅当 unsafe_comps 时),尝试否定二进制节点,例如 a = !b && !c && !d && !e → a=!(b||c||d||e) 等 注:comparisons 在启用 lhs_constants 的情况下效果最佳。

¥apply certain optimizations to binary nodes, e.g. !(a <= b) → a > b (only when unsafe_comps), attempts to negate binary nodes, e.g. a = !b && !c && !d && !e → a=!(b||c||d||e) etc. Note: comparisons works best with lhs_constants enabled.

  • computed_props (默认值: true) --

将常量计算属性转换为常规属性:{["computed"]: 1} 转换为 {computed: 1}

¥Transforms constant computed properties into regular ones: {["computed"]: 1} is converted to {computed: 1}.

  • conditionals (默认值: true) --

if-s 和条件表达式应用优化

¥apply optimizations for if-s and conditional expressions

  • dead_code (默认值: true) --

删除无法访问的代码

¥remove unreachable code

  • directives (默认值: true) --

删除冗余或非标准指令

¥remove redundant or non-standard directives

  • drop_console (默认值: false) --

传递 true 以放弃对 console.* 函数的调用。如果你只想丢弃控制台的一部分,你可以传递一个像 ['log', 'info'] 这样的数组,这样只会丢弃 console.logconsole.info

¥Pass true to discard calls to console.* functions. If you only want to discard a portion of console, you can pass an array like this ['log', 'info'], which will only discard console.logconsole.info.

  • drop_debugger (默认值: true) --

删除 debugger; 语句

¥remove debugger; statements

  • ecma (默认值: 5) --

传递 2015 或更高版本以启用 compress 选项,将 ES5 代码转换为更小的 ES6+ 等效形式。

¥Pass 2015 or greater to enable compress options that will transform ES5 code into smaller ES6+ equivalent forms.

  • evaluate (默认值: true) --

尝试计算常量表达式

¥attempt to evaluate constant expressions

  • expression (默认值: false) --

传递 true 以保留不带 return 的终端语句的完成值,例如 在小书签中。

¥Pass true to preserve completion values from terminal statements without return, e.g. in bookmarklets.

  • global_defs (默认值: {}) --

参见 条件编译

¥see conditional compilation

  • hoist_funs (默认值: false) --

提升机功能声明

¥hoist function declarations

  • hoist_props (默认值: true) --

将常量对象和数组字面量中的属性提升到受一组约束约束的常规变量中。例如:var o={p:1, q:2}; f(o.p, o.q); 转换为 f(1, 2);。注意:hoist_props 在启用 mangle、将 compress 选项 passes 设置为 2 或更高以及启用 compress 选项 toplevel 的情况下效果最佳。

¥hoist properties from constant object and array literals into regular variables subject to a set of constraints. For example: var o={p:1, q:2}; f(o.p, o.q); is converted to f(1, 2);. Note: hoist_props works best with mangle enabled, the compress option passes set to 2 or higher, and the compress option toplevel enabled.

  • hoist_vars (默认值: false) --

提升 var 声明(默认为 false,因为它通常会增加输出的大小)

¥hoist var declarations (this is false by default because it seems to increase the size of the output in general)

  • if_return (默认值: true) --

if/return 和 if/ continue 的优化

¥optimizations for if/return and if/continue

  • inline (默认值: true) --

使用 simple/return 语句内联调用函数:

¥inline calls to function with simple/return statement:

  • false - 与 0 相同

    ¥false -- same as 0

  • 0 - 禁用内联

    ¥0 -- disabled inlining

  • 1 - 内联简单函数

    ¥1 -- inline simple functions

  • 2 - 带参数的内联函数

    ¥2 -- inline functions with arguments

  • 3 - 带有参数和变量的内联函数

    ¥3 -- inline functions with arguments and variables

  • true - 与 3 相同

    ¥true -- same as 3

  • join_vars (默认值: true) --

连接连续的 varletconst 语句

¥join consecutive var, let and const statements

  • keep_classnames (默认值: false) --

传递 true 以防止压缩器丢弃类名。传递正则表达式以仅保留与该正则表达式匹配的类名。也可以看看:keep_classnames 混淆选项

¥Pass true to prevent the compressor from discarding class names. Pass a regular expression to only keep class names matching that regex. See also: the keep_classnames mangle option.

  • keep_fargs (默认值: true) --

防止压缩器丢弃未使用的函数参数。对于依赖 Function.length 的代码,你需要这个。

¥Prevents the compressor from discarding unused function arguments. You need this for code which relies on Function.length.

  • keep_fnames (默认值: false) --

传递 true 以防止压缩器丢弃函数名称。传递正则表达式以仅保留与该正则表达式匹配的函数名称。对于依赖 Function.prototype.name 的代码很有用。也可以看看:keep_fnames 混淆选项

¥Pass true to prevent the compressor from discarding function names. Pass a regular expression to only keep function names matching that regex. Useful for code relying on Function.prototype.name. See also: the keep_fnames mangle option.

  • keep_infinity (默认值: false) --

传递 true 以防止 Infinity 被压缩为 1/0,这可能会导致 Chrome 上的性能问题。

¥Pass true to prevent Infinity from being compressed into 1/0, which may cause performance issues on Chrome.

  • lhs_constants (默认值: true) --

将常量值移动到二进制节点的左侧。foo == 42 → 42 == foo

¥Moves constant values to the left-hand side of binary nodes. foo == 42 → 42 == foo

  • loops (默认值: true) --

当我们可以静态确定条件时,对 dowhilefor 循环进行优化。

¥optimizations for do, while and for loops when we can statically determine the condition.

  • module (默认值 false) --

压缩 ES6 模块时传递 true。隐含了严格模式以及 toplevel 选项。

¥Pass true when compressing an ES6 module. Strict mode is implied and the toplevel option as well.

  • negate_iife (默认值: true) --

对 "立即调用函数表达式" 取反,其中返回值被丢弃,以避免代码生成器插入括号。

¥negate "Immediately-Called Function Expressions" where the return value is discarded, to avoid the parens that the code generator would insert.

  • passes (默认值: 1) --

运行压缩的最大次数。在某些情况下,不止一次传递会导致进一步压缩代码。请记住,更多的传递将花费更多的时间。

¥The maximum number of times to run compress. In some cases more than one pass leads to further compressed code. Keep in mind more passes will take more time.

  • properties (默认值: true) --

使用点符号重写属性访问,例如 foo["bar"] → foo.bar

¥rewrite property access using the dot notation, for example foo["bar"] → foo.bar

  • pure_funcs (默认值: null) --

你可以传递名称数组,Terser 会假设这些函数不会产生副作用。危险:不会检查名称是否在范围内重新定义。这里举一个例子,比如 var q = Math.floor(a/b)。如果变量 q 没有在其他地方使用,Terser 会删除它,但仍会保留 Math.floor(a/b),但不知道它的作用。你可以传递 pure_funcs: [ 'Math.floor' ] 让它知道该函数不会产生任何副作用,在这种情况下整个语句将被丢弃。当前的实现增加了一些开销(压缩会更慢)。

¥You can pass an array of names and Terser will assume that those functions do not produce side effects. DANGER: will not check if the name is redefined in scope. An example case here, for instance var q = Math.floor(a/b). If variable q is not used elsewhere, Terser will drop it, but will still keep the Math.floor(a/b), not knowing what it does. You can pass pure_funcs: [ 'Math.floor' ] to let it know that this function won't produce any side effect, in which case the whole statement would get discarded. The current implementation adds some overhead (compression will be slower).

  • pure_getters (默认值: "strict") --

如果为此传递 true,Terser 将假定对象属性访问(例如 foo.barfoo["bar"])没有任何副作用。仅当 foo 确定不会抛出时(即不是 nullundefined),才指定 "strict"foo.bar 视为无副作用。

¥If you pass true for this, Terser will assume that object property access (e.g. foo.bar or foo["bar"]) doesn't have any side effects. Specify "strict" to treat foo.bar as side-effect-free only when foo is certain to not throw, i.e. not null or undefined.

  • pure_new (默认值: false) --

设置为 true 以假定 new X() 永远不会产生副作用。

¥Set to true to assume new X() never has side effects.

  • reduce_vars (默认值: true) --

改进对分配并用作常量值的变量的优化。

¥Improve optimization on variables assigned with and used as constant values.

  • reduce_funcs (默认值: true) --

尽可能使用内联一次性函数。取决于 reduce_vars 是否启用。禁用此选项有时会提高输出代码的性能。

¥Inline single-use functions when possible. Depends on reduce_vars being enabled. Disabling this option sometimes improves performance of the output code.

  • sequences (默认值: true) --

使用逗号运算符连接连续的简单语句。可以设置为正整数以指定将生成的连续逗号序列的最大数量。如果此选项设置为 true,则默认 sequences 限制为 200。将选项设置为 false0 以禁用。最小的 sequences 长度是 21sequences 值被继承为等于 true,因此意味着 200。在极少数情况下,默认序列限制会导致压缩时间非常慢,在这种情况下,建议使用 20 或更小的值。

¥join consecutive simple statements using the comma operator. May be set to a positive integer to specify the maximum number of consecutive comma sequences that will be generated. If this option is set to true then the default sequences limit is 200. Set option to false or 0 to disable. The smallest sequences length is 2. A sequences value of 1 is grandfathered to be equivalent to true and as such means 200. On rare occasions the default sequences limit leads to very slow compress times in which case a value of 20 or less is recommended.

  • side_effects (默认值: true) --

删除没有副作用且不使用其结果的表达式。

¥Remove expressions which have no side effects and whose results aren't used.

  • switches (默认值: true) --

去重复并删除无法访问的 switch 分支

¥de-duplicate and remove unreachable switch branches

  • toplevel (默认值: false) --

删除顶层范围中未引用的函数 ("funcs") 和/或变量 ("vars")(默认为 falsetrue 删除未引用的函数和变量)

¥drop unreferenced functions ("funcs") and/or variables ("vars") in the top level scope (false by default, true to drop both unreferenced functions and variables)

  • top_retain (默认值: null) --

防止特定的顶层函数和变量从 unused 删除(可以是数组、逗号分隔、RegExp 或函数。隐含 toplevel

¥prevent specific toplevel functions and variables from unused removal (can be array, comma-separated, RegExp or function. Implies toplevel)

  • typeofs (默认值: true) --

typeof foo == "undefined" 转换为 foo === void 0。注意:由于已知问题,对于 IE10 及更早版本,建议将此值设置为 false

¥Transforms typeof foo == "undefined" into foo === void 0. Note: recommend to set this value to false for IE10 and earlier versions due to known issues.

  • unsafe (默认值: false) --

应用 "unsafe" 转换 (details)。

¥apply "unsafe" transformations (details).

  • unsafe_arrows (默认值: false) --

如果函数体没有引用 this,则将 ES5 风格的匿名函数表达式转换为箭头函数。注意:如果代码依赖于具有 prototype 的函数(箭头函数缺少该函数),则执行此转换并不总是安全的。此转换要求将 ecma 压缩选项设置为 2015 或更大。

¥Convert ES5 style anonymous function expressions to arrow functions if the function body does not reference this. Note: it is not always safe to perform this conversion if code relies on the the function having a prototype, which arrow functions lack. This transform requires that the ecma compress option is set to 2015 or greater.

  • unsafe_comps (默认值: false) --

<<= 反转为 >>= 以改进压缩。当两个操作数中的至少一个是具有计算值的对象时,由于使用 getvalueOf 等方法,这可能是不安全的。这可能会导致比较中的操作数切换后执行顺序发生变化。仅当 comparisonsunsafe_comps 都设置为 true 时,压缩才起作用。

¥Reverse < and <= to > and >= to allow improved compression. This might be unsafe when an at least one of two operands is an object with computed values due the use of methods like get, or valueOf. This could cause change in execution order after operands in the comparison are switching. Compression only works if both comparisons and unsafe_comps are both set to true.

  • unsafe_Function (默认值: false) --

argscode 都是字符串字面量时,压缩和重整 Function(args, code)

¥compress and mangle Function(args, code) when both args and code are string literals.

  • unsafe_math (默认值: false) --

2 * x * 3 等数值表达式优化为 6 * x,这可能会给出不精确的浮点结果。

¥optimize numerical expressions like 2 * x * 3 into 6 * x, which may give imprecise floating point results.

  • unsafe_symbols (默认值: false) --

从原生符号声明中删除键,例如 Symbol("kDog") 变为 Symbol()

¥removes keys from native Symbol declarations, e.g Symbol("kDog") becomes Symbol().

  • unsafe_methods(默认值:false) - 将 { m: function(){} } 转换为 { m(){} }ecma 必须设置为 6 或更大才能启用此转换。如果 unsafe_methods 是 RegExp,则键与 RegExp 匹配的键/值对将转换为简洁方法。注意:如果启用,则任何代码尝试对前一个函数进行 new 操作时,都会有出现“<method name> 不是构造函数”TypeError 的风险。

    ¥unsafe_methods (default: false) -- Converts { m: function(){} } to { m(){} }. ecma must be set to 6 or greater to enable this transform. If unsafe_methods is a RegExp then key/value pairs with keys matching the RegExp will be converted to concise methods. Note: if enabled there is a risk of getting a "<method name> is not a constructor" TypeError should any code try to new the former function.

  • unsafe_proto (默认值: false) --

Array.prototype.slice.call(a) 等表达式优化为 [].slice.call(a)

¥optimize expressions like Array.prototype.slice.call(a) into [].slice.call(a)

  • unsafe_regexp (默认值: false) --

允许用 RegExp 值替换变量,就像它们是常量一样。

¥enable substitutions of variables with RegExp values the same way as if they are constants.

  • unsafe_undefined (默认值: false) --

如果作用域中有名为 undefined 的变量,则替换 void 0 (变量名将被破坏,通常会缩减为单个字符)

¥substitute void 0 if there is a variable named undefined in scope (variable name will be mangled, typically reduced to a single character)

  • unused (默认值: true) --

删除未引用的函数和变量(简单的直接变量赋值不计为引用,除非设置为 "keep_assign"

¥drop unreferenced functions and variables (simple direct variable assignments do not count as references unless set to "keep_assign")

混淆选项

¥Mangle options

  • eval (默认值 false) --

true 传递给在使用 evalwith 的范围内可见的 mangle 名称。

¥Pass true to mangle names visible in scopes where eval or with are used.

  • keep_classnames (默认值 false) --

传递 true 以不破坏类名。传递正则表达式以仅保留与该正则表达式匹配的类名。也可以看看:keep_classnames 压缩选项

¥Pass true to not mangle class names. Pass a regular expression to only keep class names matching that regex. See also: the keep_classnames compress option.

  • keep_fnames (默认值 false) --

传递 true 以不破坏函数名称。传递正则表达式以仅保留与该正则表达式匹配的函数名称。对于依赖 Function.prototype.name 的代码很有用。也可以看看:keep_fnames 压缩选项

¥Pass true to not mangle function names. Pass a regular expression to only keep function names matching that regex. Useful for code relying on Function.prototype.name. See also: the keep_fnames compress option.

  • module (默认值 false) --

true 传递给 ES6 模块,其中顶层作用域不是全局作用域。暗示 toplevel 并假设输入代码是严格模式 JS。

¥Pass true an ES6 modules, where the toplevel scope is not the global scope. Implies toplevel and assumes input code is strict mode JS.

  • nth_identifier(默认值:根据字符频率分析进行加权的内部混淆器) - 传递带有 get(n) 函数的对象,该函数将序数转换为第 n 个最受青睐(通常是最短)的标识符。还可以选择提供 reset()sort()consider(chars, delta) 以使用源代码的字符频率分析。

    ¥nth_identifier (default: an internal mangler that weights based on character frequency analysis) -- Pass an object with a get(n) function that converts an ordinal into the nth most favored (usually shortest) identifier. Optionally also provide reset(), sort(), and consider(chars, delta) to use character frequency analysis of the source code.

  • reserved (默认值 []) --

传递应从重整中排除的标识符数组。示例:["foo", "bar"]

¥Pass an array of identifiers that should be excluded from mangling. Example: ["foo", "bar"].

  • toplevel (默认值 false) --

true 传递给顶层范围中声明的 mangle 名称。

¥Pass true to mangle names declared in the top level scope.

  • safari10 (默认值 false) --

传递 true 以解决 Safari 10 循环迭代器 bug "不能两次声明 let 变量" 的问题。也可以看看:safari10 格式选项

¥Pass true to work around the Safari 10 loop iterator bug "Cannot declare a let variable twice". See also: the safari10 format option.

示例:

¥Examples:

// test.js
var globalVar;
function funcName(firstLongName, anotherLongName) {
var myVariable = firstLongName + anotherLongName;
}
var code = fs.readFileSync("test.js", "utf8");

await minify(code).code;
// 'function funcName(a,n){}var globalVar;'

await minify(code, { mangle: { reserved: ['firstLongName'] } }).code;
// 'function funcName(firstLongName,a){}var globalVar;'

await minify(code, { mangle: { toplevel: true } }).code;
// 'function n(n,a){}var a;'

混淆属性选项

¥Mangle properties options

  • builtins(默认值:false) - 使用 true 允许修改内置 DOM 属性。不建议覆盖此设置。

    ¥builtins (default: false) — Use true to allow the mangling of builtin DOM properties. Not recommended to override this setting.

  • debug(默认值:false) - Mangle 名称,原始名称仍然存在。传递一个空字符串 "" 来启用,或传递一个非空字符串来设置调试后缀。

    ¥debug (default: false) — Mangle names with the original name still present. Pass an empty string "" to enable, or a non-empty string to set the debug suffix.

  • keep_quoted(默认值:false)—引用属性({"prop": ...}obj["prop"])如何控制混淆的内容。

    ¥keep_quoted (default: false) — How quoting properties ({"prop": ...} and obj["prop"]) controls what gets mangled.

    • "strict"(推荐)--obj.prop 已混淆。

      ¥"strict" (recommended) -- obj.prop is mangled.

    • false - obj["prop"] 已混淆。

      ¥false -- obj["prop"] is mangled.

    • true - obj.prop 被破坏,除非代码中其他地方有 obj["prop"]

      ¥true -- obj.prop is mangled unless there is obj["prop"] elsewhere in the code.

  • nth_identifier(默认值:根据字符频率分析进行加权的内部混淆器) - 传递带有 get(n) 函数的对象,该函数将序数转换为第 n 个最受青睐(通常是最短)的标识符。还可以选择提供 reset()sort()consider(chars, delta) 以使用源代码的字符频率分析。

    ¥nth_identifier (default: an internal mangler that weights based on character frequency analysis) -- Pass an object with a get(n) function that converts an ordinal into the nth most favored (usually shortest) identifier. Optionally also provide reset(), sort(), and consider(chars, delta) to use character frequency analysis of the source code.

  • regex(默认值:null)— 将 RegExp 字面量或模式字符串 传递给仅与正则表达式匹配的 mangle 属性。

    ¥regex (default: null) — Pass a RegExp literal or pattern string to only mangle property matching the regular expression.

  • reserved(默认值:[])— 不要破坏 reserved 数组中列出的属性名称。

    ¥reserved (default: []) — Do not mangle property names listed in the reserved array.

  • undeclared (默认值: false) -

当这些名称作为已知顶层变量的属性进行访问但在输入代码中从未找到它们的声明时,会破坏这些名称。当仅压缩项目的一部分时可能很有用。详细信息请参见 #397

¥Mangle those names when they are accessed as properties of known top level variables but their declarations are never found in input code. May be useful when only minifying parts of a project. See #397 for more details.

格式选项

¥Format options

这些选项控制 Terser 输出代码的格式。以前称为 "输出选项"。

¥These options control the format of Terser's output code. Previously known as "output options".

  • ascii_only (默认值 false) --

转义字符串和正则表达式中的 Unicode 字符(影响非 ASCII 字符无效的指令)

¥escape Unicode characters in strings and regexps (affects directives with non-ascii characters becoming invalid)

  • beautify (默认值 false) --

(已弃用)是否美化输出。当使用旧版 -b CLI 标志时,默认设置为 true。

¥(DEPRECATED) whether to beautify the output. When using the legacy -b CLI flag, this is set to true by default.

  • braces (默认值 false) --

始终在 iffordowhilewith 语句中插入大括号,即使它们的主体是单个语句。

¥always insert braces in if, for, do, while or with statements, even if their body is a single statement.

  • comments (默认值 "some") --

默认情况下,它保留包含 "@license"、"@copyright"、"@preserve" 或以 ! 开头的 JSDoc 风格注释,传递 true"all" 来保留所有注释,传递 false 来省略输出中的注释、正则表达式字符串(例如 /^!/)或函数。

¥by default it keeps JSDoc-style comments that contain "@license", "@copyright", "@preserve" or start with !, pass true or "all" to preserve all comments, false to omit comments in the output, a regular expression string (e.g. /^!/) or a function.

  • ecma (默认值 5) --

设置输出所需的 EcmaScript 标准版本。将 ecma 设置为 2015 或更大以触发简写对象属性 - 例如:{a} 而不是 {a: a}ecma 选项只会改变直接控制美化器的输出。输入中不兼容的功能仍将按原样输出。例如:ecma 设置为 5 不会将现代代码转换为 ES5。

¥set desired EcmaScript standard version for output. Set ecma to 2015 or greater to emit shorthand object properties - i.e.: {a} instead of {a: a}. The ecma option will only change the output in direct control of the beautifier. Non-compatible features in your input will still be output as is. For example: an ecma setting of 5 will not convert modern code to ES5.

  • indent_level(默认 4

    ¥indent_level (default 4)

  • indent_start (默认值 0) --

在所有行前面添加那么多空格

¥prefix all lines by that many spaces

  • inline_script (默认值 true) --

转义 HTML 注释和字符串中 </script> 出现的斜杠

¥escape HTML comments and the slash in occurrences of </script> in strings

  • keep_numbers (默认值 false) --

保留原始代码中的数字字面量(禁用诸如将 1000000 转换为 1e6 之类的优化)

¥keep number literals as it was in original code (disables optimizations like converting 1000000 into 1e6)

  • keep_quoted_props (默认值 false) --

打开时,可防止从对象字面量中的属性名称中去除引号。

¥when turned on, prevents stripping quotes from property names in object literals.

  • max_line_len (默认值 false) --

最大行长度(对于精简代码)

¥maximum line length (for minified code)

  • preamble (默认值 null) --

传递时它必须是一个字符串,并且它将按字面意思添加到输出之前。源映射将针对此文本进行调整。例如,可用于插入包含许可信息的注释。

¥when passed it must be a string and it will be prepended to the output literally. The source map will adjust for this text. Can be used to insert a comment containing licensing information, for example.

  • quote_keys (默认值 false) --

通过 true 来引用字面量对象中的所有键

¥pass true to quote all keys in literal objects

  • quote_style (默认值 0) --

字符串的首选引号样式(也会影响带引号的属性名称和指令):

¥preferred quote style for strings (affects quoted property names and directives as well):

  • 0 -- 更喜欢双引号,当字符串本身有更多双引号时切换到单引号。0 最适合 gzip 大小。

    ¥0 -- prefers double quotes, switches to single quotes when there are more double quotes in the string itself. 0 is best for gzip size.

  • 1 - 始终使用单引号

    ¥1 -- always use single quotes

  • 2 - 始终使用双引号

    ¥2 -- always use double quotes

  • 3 - 始终使用原始引号

    ¥3 -- always use the original quotes

  • preserve_annotations --(默认 false) -- 在输出中保留 简洁的注释

    ¥preserve_annotations -- (default false) -- Preserve Terser annotations in the output.

  • safari10 (默认值 false) --

将此选项设置为 true 以解决 Safari 10/11 等待 bug 问题。也可以看看:safari10 混淆选项

¥set this option to true to work around the Safari 10/11 await bug. See also: the safari10 mangle option.

  • semicolons (默认值 true) --

用分号分隔语句。如果你传递 false,那么只要有可能,我们将使用换行符而不是分号,从而使压缩代码的输出更具可读性(gzip 之前的大小可能会更小;gzip 之后的大小会稍微大一些)。

¥separate statements with semicolons. If you pass false then whenever possible we will use a newline instead of a semicolon, leading to more readable output of minified code (size before gzip could be smaller; size after gzip insignificantly larger).

  • shebang (默认值 true) --

在序言中保留 shebang #!(bash 脚本)

¥preserve shebang #! in preamble (bash scripts)

  • spidermonkey (默认值 false) --

生成 Spidermonkey (Mozilla) AST

¥produce a Spidermonkey (Mozilla) AST

  • webkit (默认值 false) --

启用 WebKit 错误的解决方法。PhantomJS 用户应将此选项设置为 true

¥enable workarounds for WebKit bugs. PhantomJS users should set this option to true.

  • wrap_iife (默认值 false) --

传递 true 来封装立即调用的函数表达式。详细信息请参见 #640

¥pass true to wrap immediately invoked function expressions. See #640 for more details.

  • wrap_func_args (默认值 true) --

如果你不想将作为参数传递的函数表达式封装在括号中,请传递 false。详细信息请参见 OptimizeJS

¥pass false if you do not want to wrap function expressions that are passed as arguments, in parenthesis. See OptimizeJS for more details.