Exclude debug JavaScript code during minification

后端 未结 11 2019
庸人自扰
庸人自扰 2020-11-28 07:16

I\'m looking into different ways to minify my JavaScript code including the regular JSMin, Packer, and YUI solutions. I\'m really interested in the new Google Closure Compil

11条回答
  •  醉酒成梦
    2020-11-28 07:34

    here's the (ultimate) answer for closure compiler :

    /** @const */
    var LOG = false;
    ...
    LOG && log('hello world !'); // compiler will remove this line
    ...
    

    this will even work with SIMPLE_OPTIMIZATIONS and no --define= is necessary !

提交回复
热议问题