Tell UglifyJS to skip a particular area of code
Asked Answered
P

2

12

Is there a way to tell UglifyJS to skip a particular section of code, perhaps using comments like this:

// uglifyjs:skipStart
filter = function(item){ /* some crazy filter logic that will repeat 500,000 times */ }
// uglifyjs:skipEnd

My use case has to do with avoiding the minification of a function that will be inlined and parsed in a custom way for performance gain. Minification breaks the simplified parser.

Pyromagnetic answered 9/1, 2014 at 20:24 Comment(2)
Smartaleck answer: use coffeescript :) But serious, nope, haven't.Pyromagnetic
still looking for a solution too. @SimplGy, did you find anything?Eryn
P
0

Unfortunately, there is not a way to do this.

Pyromagnetic answered 24/3, 2017 at 19:0 Comment(0)
G
-1

The Global Definitions of Uglify Compressor is a feature you can use in order to conditionally drop code.

    global_defs: {
      DEBUG: false
    }

the compressor will assume that's a constant defintion and will discard code like this as being unreachable:

    if (DEBUG) {
      ...
    }

http://lisperator.net/uglifyjs/compress

Giese answered 24/11, 2017 at 12:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.