11

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.

SimplGy
  • 18,875
  • 14
  • 95
  • 138

2 Answers2

0

Unfortunately, there is not a way to do this.

SimplGy
  • 18,875
  • 14
  • 95
  • 138
-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