<h1><img src="https://terser.org/img/terser-banner-logo.png" alt="Terser" width="400"></h1>
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![CI pipeline][ci-image]][ci-url]
[![Opencollective financial contributors][opencollective-contributors]][opencollective-url]
A JavaScript mangler/compressor toolkit for ES6+.
*note*: <s>You can support this project on patreon: [link]</s> **The Terser Patreon is shutting down in favor of opencollective**. Check out [PATRONS.md](https://github.com/terser/terser/blob/master/PATRONS.md) for our first-tier patrons.
Terser recommends you use RollupJS to bundle your modules, as that produces smaller code overall.
*Beautification* has been undocumented and is *being removed* from terser, we recommend you use [prettier](https://npmjs.com/package/prettier).
Find the changelog in [CHANGELOG.md](https://github.com/terser/terser/blob/master/CHANGELOG.md)
[npm-image]: https://img.shields.io/npm/v/terser.svg
[npm-url]: https://npmjs.org/package/terser
[downloads-image]: https://img.shields.io/npm/dm/terser.svg
[downloads-url]: https://npmjs.org/package/terser
[ci-image]: https://github.com/terser/terser/actions/workflows/ci.yml/badge.svg
[ci-url]: https://github.com/terser/terser/actions/workflows/ci.yml
[opencollective-contributors]: https://opencollective.com/terser/tiers/badge.svg
[opencollective-url]: https://opencollective.com/terser
Why choose terser?
------------------
`uglify-es` is [no longer maintained](https://github.com/mishoo/UglifyJS2/issues/3156#issuecomment-392943058) and `uglify-js` does not support ES6+.
**`terser`** is a fork of `uglify-es` that mostly retains API and CLI compatibility
with `uglify-es` and `uglify-js@3`.
Install
-------
First make sure you have installed the latest version of [node.js](http://nodejs.org/)
(You may need to restart your computer after this step).
From NPM for use as a command line app:
npm install terser -g
From NPM for programmatic use:
npm install terser
# Command line usage
<!-- CLI_USAGE:START -->
```
terser [input files] [options]
```
Terser can take multiple input files. It's recommended that you pass the
input files first, then pass the options. Terser will parse input files
in sequence and apply any compression options. The files are parsed in the
same global scope, that is, a reference from a file to some
variable/function declared in another file will be matched properly.
Command line arguments that take options (like --parse, --compress, --mangle and
--format) can take in a comma-separated list of default option overrides. For
instance:
terser input.js --compress ecma=2015,computed_props=false
If no input file is specified, Terser will read from STDIN.
If you wish to pass your options before the input files, separate the two with
a double dash to prevent input files being used as option arguments:
terser --compress --mangle -- input.js
### Command line options
```
-h, --help Print usage information.
`--help options` for details on available options.
-V, --version Print version number.
-p, --parse <options> Specify parser options:
`acorn` Use Acorn for parsing.
`bare_returns` Allow return outside of functions.
Useful when minifying CommonJS
modules and Userscripts that may
be anonymous function wrapped (IIFE)
by the .user.js engine `caller`.
`expression` Parse a single expression, rather than
a program (for parsing JSON).
`spidermonkey` Assume input files are SpiderMonkey
AST format (as JSON).
-c, --compress [options] Enable compressor/specify compressor options:
`pure_funcs` List of functions that can be safely
removed when their return values are
not used.
-m, --mangle [options] Mangle names/specify mangler options:
`reserved` List of names that should not be mangled.
--mangle-props [options] Mangle properties/specify mangler options:
`builtins` Mangle property names that overlaps
with standard JavaScript globals and DOM
API props.
`debug` Add debug prefix and suffix.
`keep_quoted` Only mangle unquoted properties, quoted
properties are automatically reserved.
`strict` disables quoted properties
being automatically reserved.
`regex` Only mangle matched property names.
`only_annotated` Only mangle properties defined with /*@__MANGLE_PROP__*/.
`reserved` List of names that should not be mangled.
-f, --format [options] Specify format options.
`preamble` Preamble to prepend to the output. You
can use this to insert a comment, for
example for licensing information.
This will not be parsed, but the source
map will adjust for its presence.
`quote_style` Quote style:
0 - auto
1 - single
2 - double
3 - original
`wrap_iife` Wrap IIFEs in parenthesis. Note: you may
want to disable `negate_iife` under
compressor options.
`wrap_func_args` Wrap function arguments in parenthesis.
-o, --output <file> Output file path (default STDOUT). Specify `ast` or
`spidermonkey` to write Terser or SpiderMonkey AST
as JSON to STDOUT respectively.
--comments [filter] Preserve copyright comments in the output. By
default this works like Google Closure, keeping
JSDoc-style comments that contain e.g. "@license",
or start with "!". You can optionally pass one of the
following arguments to this flag:
- "all" to keep all comments
- `false` to omit comments in the output
- a valid JS RegExp like `/foo/` or `/^!/` to
keep only matching comments.
Note that currently not *all* comments can be
kept when compression is on, because of dead
code removal or cascading statements into
sequences.
--config-file <file> Read `minify()` options from JSON file.
-d, --define <expr>[=value] Global definitions.
--ecma <version> Specify ECMAScript release: 5, 2015, 2016, etc.
-e, --enclose [arg[:value]] Embed output in a big function with configurable
没有合适的资源?快使用搜索试试~ 我知道了~
emsdk-3.1.54
共2000个文件
py:1219个
md:285个
js:229个
需积分: 5 0 下载量 40 浏览量
2024-02-22
18:38:37
上传
评论
收藏 534.8MB ZIP 举报
温馨提示
emsdk-3.1.54
资源推荐
资源详情
资源评论
收起资源包目录
emsdk-3.1.54 (2000个子文件)
_pydoc.css 102B
unicodeobject.h 45KB
unicodeobject.h 36KB
pyport.h 31KB
abstract.h 31KB
Python-ast.h 26KB
object.h 25KB
dynamic_annotations.h 22KB
pyconfig.h 20KB
object.h 19KB
pycore_atomic.h 17KB
initconfig.h 17KB
abstract.h 14KB
pyerrors.h 12KB
pystate.h 10KB
modsupport.h 10KB
longobject.h 10KB
datetime.h 9KB
pytime.h 9KB
pymath.h 9KB
objimpl.h 8KB
pythonrun.h 8KB
code.h 7KB
codecs.h 7KB
pycore_gc.h 7KB
ceval.h 6KB
pythread.h 6KB
pycore_interp.h 5KB
symtable.h 5KB
pystate.h 5KB
pycore_initconfig.h 5KB
pyerrors.h 5KB
pymacro.h 5KB
opcode.h 5KB
objimpl.h 4KB
pycore_runtime.h 4KB
pymem.h 4KB
floatobject.h 4KB
pyhash.h 4KB
pycore_hashtable.h 4KB
bytesobject.h 4KB
fileutils.h 4KB
pycore_object.h 4KB
funcobject.h 4KB
pycore_ceval.h 4KB
longintrepr.h 4KB
compile.h 4KB
dictobject.h 4KB
methodobject.h 4KB
pycore_pylifecycle.h 4KB
Python.h 4KB
dictobject.h 4KB
pycore_pystate.h 4KB
genobject.h 4KB
pymem.h 4KB
pycore_pymem.h 3KB
pycore_bytes_methods.h 3KB
setobject.h 3KB
pycore_hamt.h 3KB
pycore_traceback.h 3KB
frameobject.h 3KB
bytesobject.h 3KB
descrobject.h 3KB
import.h 3KB
pymacconfig.h 3KB
parsetok.h 3KB
weakrefobject.h 3KB
pycore_condvar.h 3KB
memoryobject.h 3KB
pyarena.h 3KB
token.h 3KB
pycore_byteswap.h 3KB
sliceobject.h 3KB
py_curses.h 3KB
pyexpat.h 2KB
pydtrace.h 2KB
moduleobject.h 2KB
typeslots.h 2KB
pylifecycle.h 2KB
graminit.h 2KB
pylifecycle.h 2KB
pycore_pyerrors.h 2KB
structmember.h 2KB
context.h 2KB
pycore_pathconfig.h 2KB
grammar.h 2KB
complexobject.h 2KB
warnings.h 2KB
listobject.h 2KB
pycapsule.h 2KB
classobject.h 2KB
errcode.h 2KB
tupleobject.h 2KB
fileobject.h 2KB
pycore_gil.h 2KB
ceval.h 2KB
bytearrayobject.h 1KB
pystrtod.h 1KB
import.h 1KB
structseq.h 1KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
chen1711786767
- 粉丝: 2
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功