Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法告诉 UglifyJS 跳过特定的代码部分,可能使用如下注释:
// uglifyjs:skipStart filter = function(item){ /* some crazy filter logic that will repeat 500,000 times */ } // uglifyjs:skipEnd
我的用例与避免缩小将内联并以自定义方式解析以提高性能的函数有关。缩小会破坏简化的解析器。
不幸的是,没有办法做到这一点。
Uglify Compressor 的全局定义是您可以用来有条件地删除代码的功能。
global_defs: { DEBUG: false }
压缩器将假定这是一个常量定义,并将像这样的代码丢弃为不可访问:
if (DEBUG) { ... }
http://lisperator.net/uglifyjs/compress