• Version 3.17.5
  • Published
  • 20.4 kB
  • 1 dependency
  • MIT license


npm i @types/uglify-js
yarn add @types/uglify-js
pnpm add @types/uglify-js


TypeScript definitions for uglify-js



function minify

minify: (
files: string | string[] | { [file: string]: string },
options?: MinifyOptions
) => MinifyOutput;


    interface CompressOptions

    interface CompressOptions {}

      property arguments

      arguments?: boolean | undefined;
      • Replace arguments[index] with function parameter name whenever possible. true

      property assignments

      assignments?: boolean | undefined;
      • Apply optimizations to assignment expressions true

      property booleans

      booleans?: boolean | undefined;
      • Various optimizations for boolean context, for example !!a ? b : c → a ? b : c true

      property collapse_vars

      collapse_vars?: boolean | undefined;
      • Collapse single-use non-constant variables, side effects permitting. true

      property comparisons

      comparisons?: boolean | undefined;
      • Apply certain optimizations to binary nodes, e.g. !(a <= b) → a > b, attempts to negate binary nodes, e.g. a = !b && !c && !d && !e → a=!(b||c||d||e) etc true

      property conditionals

      conditionals?: boolean | undefined;
      • Apply optimizations for if-s and conditional expressions. true

      property dead_code

      dead_code?: boolean | undefined;
      • Remove unreachable code true

      property directives

      directives?: boolean | undefined;
      • remove redundant or non-standard directives true

      property drop_console

      drop_console?: boolean | undefined;
      • Pass true to discard calls to console.* functions. If you wish to drop a specific function call such as console.info and/or retain side effects from function arguments after dropping the function call then use pure_funcs instead. true

      property drop_debugger

      drop_debugger?: boolean | undefined;
      • Remove debugger; statements true

      property evaluate

      evaluate?: boolean | undefined;
      • Attempt to evaluate constant expressions true

      property expression

      expression?: boolean | undefined;
      • Pass true to preserve completion values from terminal statements without return, e.g. in bookmarklets. false

      property functions

      functions?: boolean | undefined;
      • convert declarations from varto function whenever possible true

      property global_defs

      global_defs?: object | undefined;
      • {}

      property hoist_exports

      hoist_exports?: boolean | undefined;
      • hoist export statements to facilitate various compress and mangle optimizations. true

      property hoist_funs

      hoist_funs?: boolean | undefined;

        property hoist_props

        hoist_props?: boolean | undefined;
        • 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. true

        property hoist_vars

        hoist_vars?: boolean | undefined;
        • Hoist var declarations (this is false by default because it seems to increase the size of the output in general) false

        property if_return

        if_return?: boolean | undefined;
        • Optimizations for if/return and if/continue true

        property imports

        imports?: boolean | undefined;
        • drop unreferenced import symbols when used with unused true

        property inline

        inline?: boolean | InlineFunctions | undefined;
        • Inline calls to function with simple/return statement - false -- same as Disabled - Disabled -- disabled inlining - SimpleFunctions -- inline simple functions - WithArguments -- inline functions with arguments - WithArgumentsAndVariables -- inline functions with arguments and variables - true -- same as WithArgumentsAndVariables true

        property join_vars

        join_vars?: boolean | undefined;
        • join consecutive var statements true

        property keep_fargs

        keep_fargs?: 'strict' | boolean | undefined;
        • Prevents the compressor from discarding unused function arguments. You need this for code which relies on Function.length 'strict'

        property keep_fnames

        keep_fnames?: boolean | undefined;
        • Pass true to prevent the compressor from discarding function names. Useful for code relying on Function.prototype.name. false

        property keep_infinity

        keep_infinity?: boolean | undefined;
        • Pass true to prevent Infinity from being compressed into 1/0, which may cause performance issues on Chrome false

        property loops

        loops?: boolean | undefined;
        • Optimizations for do, while and for loops when we can statically determine the condition. true

        property merge_vars

        merge_vars?: boolean | undefined;
        • combine and reuse variables. true

        property module

        module?: boolean | undefined;
        • set to true if you wish to process input as ES module, i.e. implicit "use strict"; alongside with toplevel enabled. false

        property negate_iife

        negate_iife?: boolean | undefined;
        • negate Immediately-Called Function Expressions where the return value is discarded, to avoid the parens that the code generator would insert. true

        property objects

        objects?: boolean | undefined;
        • compact duplicate keys in object literals true

        property passes

        passes?: number | undefined;
        • 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. 1

        property properties

        properties?: boolean | undefined;
        • Rewrite property access using the dot notation, for example foo["bar"] to foo.bar true

        property pure_funcs

        pure_funcs?: string[] | null | undefined;
        • An array of names and UglifyJS 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, UglifyJS 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). null

        property pure_getters

        pure_getters?: boolean | 'strict' | undefined;
        • If you pass true for this, UglifyJS 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 undefine 'strict'

        property reduce_funcs

        reduce_funcs?: boolean | undefined;
        • Allows single-use functions to be inlined as function expressions when permissible allowing further optimization. Enabled by default. Option depends on reduce_vars being enabled. Some code runs faster in the Chrome V8 engine if this option is disabled. Does not negatively impact other major browsers. true

        property reduce_vars

        reduce_vars?: boolean | undefined;
        • Improve optimization on variables assigned with and used as constant values. true

        property sequences

        sequences?: boolean | undefined;
        • 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 true

        property side_effects

        side_effects?: boolean | undefined;
        • Pass false to disable potentially dropping functions marked as "pure". true

        property strings

        strings?: boolean | undefined;
        • compact string concatenations true

        property switches

        switches?: boolean | undefined;
        • De-duplicate and remove unreachable switch branches. true

        property templates

        templates?: boolean | undefined;
        • Compact template literals by embedding expressions and/or converting to string literals, e.g. foo ${42} → "foo 42" true

        property top_retain

        top_retain?: boolean | null | undefined;
        • Prevent specific toplevel functions and variables from unused removal (can be array, comma-separated, RegExp or function. Implies toplevel) null

        property toplevel

        toplevel?: boolean | undefined;
        • Drop unreferenced functions ("funcs") and/or variables ("vars") in the top level scope (false by default, true to drop both unreferenced functions and variables) false

        property typeofs

        typeofs?: boolean | undefined;
        • 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 true

        property unsafe

        unsafe?: boolean | undefined;
        • apply "unsafe" transformations (discussion below) false

        property unsafe_comps

        unsafe_comps?: boolean | undefined;
        • Compress expressions like a <= b assuming none of the operands can be (coerced to) NaN. false

        property unsafe_Function

        unsafe_Function?: boolean | undefined;
        • Compress and mangle Function(args, code) when both args and code are string literals. false

        property unsafe_math

        unsafe_math?: boolean | undefined;
        • Optimize numerical expressions like 2 * x * 3 into 6 * x, which may give imprecise floating point results. false

        property unsafe_proto

        unsafe_proto?: boolean | undefined;
        • Optimize expressions like Array.prototype.slice.call(a) into [].slice.call(a) false

        property unsafe_regexp

        unsafe_regexp?: boolean | undefined;
        • Enable substitutions of variables with RegExp values the same way as if they are constants. false

        property unsafe_undefined

        unsafe_undefined?: boolean | undefined;
        • substitute void 0 if there is a variable named undefined in scope (variable name will be mangled, typically reduced to a single character) false

        property unused

        unused?: boolean | undefined;
        • drop unreferenced functions and variables (simple direct variable assignments do not count as references unless set to "keep_assign") true

        property varify

        varify?: boolean | undefined;
        • convert block-scoped declaractions into var whenever safe to do so true

        property webkit

        webkit?: boolean | undefined;
        • Support non-standard Safari/Webkit. By default UglifyJS will not try to be Safari-proof. false

        interface MangleOptions

        interface MangleOptions {}

          property eval

          eval?: boolean | undefined;
          • Pass true to mangle names visible in scopes where eval or with are used.

          property keep_fnames

          keep_fnames?: boolean | undefined;
          • Pass true to not mangle function names. Useful for code relying on Function.prototype.name.

          property properties

          properties?: boolean | ManglePropertiesOptions | undefined;

            property reserved

            reserved?: string[] | undefined;
            • Pass an array of identifiers that should be excluded from mangling. Example: ["foo", "bar"].

            property toplevel

            toplevel?: boolean | undefined;
            • Pass true to mangle names declared in the top level scope.

            interface ManglePropertiesOptions

            interface ManglePropertiesOptions {}

              property builtins

              builtins?: boolean | undefined;
              • Use true to allow the mangling of builtin DOM properties. Not recommended to override this setting.

              property debug

              debug?: boolean | undefined;
              • Mangle names with the original name still present. Pass an empty string "" to enable, or a non-empty string to set the debug suffix.

              property keep_quoted

              keep_quoted?: boolean | undefined;
              • Only mangle unquoted property names

              property regex

              regex?: RegExp | undefined;
              • Pass a RegExp literal to only mangle property names matching the regular expression.

              property reserved

              reserved?: string[] | undefined;
              • Do not mangle property names listed in the reserved array

              interface MinifyOptions

              interface MinifyOptions {}

                property compress

                compress?: false | CompressOptions | undefined;
                • Pass false to skip compressing entirely. Pass an object to specify custom compress options. {}

                property expression

                expression?: boolean | undefined;
                • Parse as a single expression, e.g. JSON. false

                property ie8

                ie8?: boolean | undefined;
                • Set to true to support IE8 false

                property keep_fnames

                keep_fnames?: boolean | undefined;
                • Pass true to prevent discarding or mangling of function names. Useful for code relying on Function.prototype.name. false

                property mangle

                mangle?: boolean | MangleOptions | undefined;
                • Pass false to skip mangling names, or pass an object to specify mangle options (see below). true

                property module

                module?: boolean | undefined;
                • set to true if you wish to process input as ES module, i.e. implicit "use strict"; alongside with toplevel enabled. false

                property nameCache

                nameCache?: object | undefined;
                • Pass an empty object {} or a previously used nameCache object if you wish to cache mangled variable and property names across multiple invocations of minify(). Note: this is a read/write property. minify() will read the name cache state of this object and update it during minification so that it may be reused or externally persisted by the user

                property output

                output?: OutputOptions | undefined;
                • Pass an object if you wish to specify additional output options. The defaults are optimized for best compression

                property parse

                parse?: ParseOptions | undefined;
                • Pass an object if you wish to specify some additional parse options.

                property sourceMap

                sourceMap?: boolean | SourceMapOptions | undefined;
                • Pass an object if you wish to specify source map options. false

                property toplevel

                toplevel?: boolean | undefined;
                • Set to true if you wish to enable top level variable and function name mangling and to drop unused variables and functions. false

                property warnings

                warnings?: boolean | 'verbose' | undefined;
                • Pass true to return compressor warnings in result.warnings. Use the value verbose for more detailed warnings. false

                property webkit

                webkit?: boolean | undefined;
                • Support non-standard Safari/Webkit. Equivalent to setting webkit: true in minify() for compress, mangle and output options. false

                interface MinifyOutput

                interface MinifyOutput {}

                  property code

                  code: string;

                    property error

                    error?: Error | undefined;

                      property map

                      map: string;

                        property warnings

                        warnings?: string[] | undefined;

                          interface OutputOptions

                          interface OutputOptions {}

                            property ascii_only

                            ascii_only?: boolean | undefined;

                              property beautify

                              beautify?: boolean | undefined;

                                property braces

                                braces?: boolean | undefined;

                                  property comments

                                  comments?: boolean | 'all' | 'some' | RegExp | undefined;

                                    property indent_level

                                    indent_level?: number | undefined;

                                      property indent_start

                                      indent_start?: boolean | undefined;

                                        property inline_script

                                        inline_script?: boolean | undefined;

                                          property keep_quoted_props

                                          keep_quoted_props?: boolean | undefined;

                                            property max_line_len

                                            max_line_len?: boolean | number | undefined;

                                              property preamble

                                              preamble?: string | undefined;

                                                property preserve_line

                                                preserve_line?: boolean | undefined;

                                                  property quote_keys

                                                  quote_keys?: boolean | undefined;

                                                    property quote_style

                                                    quote_style?: OutputQuoteStyle | undefined;

                                                      property semicolons

                                                      semicolons?: boolean | undefined;

                                                        property shebang

                                                        shebang?: boolean | undefined;

                                                          property webkit

                                                          webkit?: boolean | undefined;

                                                            property width

                                                            width?: number | undefined;

                                                              property wrap_iife

                                                              wrap_iife?: boolean | undefined;

                                                                interface ParseOptions

                                                                interface ParseOptions {}

                                                                  property bare_returns

                                                                  bare_returns?: boolean | undefined;
                                                                  • Support top level return statements false

                                                                  property html5_comments

                                                                  html5_comments?: boolean | undefined;
                                                                  • true

                                                                  property shebang

                                                                  shebang?: boolean | undefined;
                                                                  • Support #!command as the first line true

                                                                  interface SourceMapOptions

                                                                  interface SourceMapOptions {}

                                                                    property content

                                                                    content?: RawSourceMap | 'inline' | undefined;

                                                                      property filename

                                                                      filename?: string | undefined;

                                                                        property includeSources

                                                                        includeSources?: boolean | undefined;

                                                                          property names

                                                                          names?: boolean | undefined;
                                                                          • Include symbol names in the source map true

                                                                          property root

                                                                          root?: string | undefined;

                                                                            property url

                                                                            url?: string | 'inline' | undefined;


                                                                              enum InlineFunctions

                                                                              enum InlineFunctions {
                                                                              Disabled = 0,
                                                                              SimpleFunctions = 1,
                                                                              WithArguments = 2,
                                                                              WithArgumentsAndVariables = 3,

                                                                                member Disabled

                                                                                Disabled = 0

                                                                                  member SimpleFunctions

                                                                                  SimpleFunctions = 1

                                                                                    member WithArguments

                                                                                    WithArguments = 2

                                                                                      member WithArgumentsAndVariables

                                                                                      WithArgumentsAndVariables = 3

                                                                                        enum OutputQuoteStyle

                                                                                        enum OutputQuoteStyle {
                                                                                        PreferDouble = 0,
                                                                                        AlwaysSingle = 1,
                                                                                        AlwaysDouble = 2,
                                                                                        AlwaysOriginal = 3,

                                                                                          member AlwaysDouble

                                                                                          AlwaysDouble = 2

                                                                                            member AlwaysOriginal

                                                                                            AlwaysOriginal = 3

                                                                                              member AlwaysSingle

                                                                                              AlwaysSingle = 1

                                                                                                member PreferDouble

                                                                                                PreferDouble = 0

                                                                                                  Package Files (1)

                                                                                                  Dependencies (1)

                                                                                                  Dev Dependencies (0)

                                                                                                  No dev dependencies.

                                                                                                  Peer Dependencies (0)

                                                                                                  No peer dependencies.


                                                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/uglify-js.

                                                                                                  • Markdown
                                                                                                  • HTML
                                                                                                    <a href="https://www.jsdocs.io/package/@types/uglify-js"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>