Skip to content

const name length influences uglified code despite mangle #1194

@kzc

Description

@kzc

The two JS functions below are identical except for the const variable name length. They produce different output - even when mangled:

$ echo 'function f() {const a = "X"; return a + a;}' | uglifyjs -cm
function f(){const n="X";return n+n}
$ echo 'function f() {const aa = "X"; return aa + aa;}' | uglifyjs -cm
function f(){return"XX"}

Running compress before mangle in bin/uglifyjs may have something to do with this. Either that or compress needs a better heuristic governing when const substitution should take place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions