Exclude debug JavaScript code during minification

后端 未结 11 2007
庸人自扰
庸人自扰 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:25

    Adding logic to every place in your code where you are logging to the console makes it harder to debug and maintain.

    If you are already going to add a build step for your production code, you could always add another file at the top that turns your console methods into noop's.

    Something like:

    console.log = console.debug = console.info = function(){};
    

    Ideally, you'd just strip out any console methods, but if you are keeping them in anyway but not using them, this is probably the easiest to work with.

提交回复
热议问题