只是想我会帮助遇到这个问题的任何人。
我已经开始使用 Google 的Closure Comiler来为一个项目缩小 JS,它给了我一些方便的警告。
   $> java -jar google_closure_compiler.jar  --language_in=ECMASCRIPT5_STRICT --js_output_file 'min.js' 'file1.js' 'file2.js'
   file1.js:152: WARNING - unreachable code
               getSomething(function() { return this.doThingo(''); });
               ^
   file2.js:203: WARNING - Suspicious code. The result of the 'add' operator is not being used.
               ' to ' + (typeof obj);
               ^
   0 error(s), 2 warning(s)
有问题的代码块如下(注释描述了编译器提醒我的代码丢失了什么):
文件 1.js:150
    return generateSomeObject(bunch, of, arguments)
        //the period before the function call was missing
        getSomething(function() { return this.doThingo(''); });
}
文件 2.js:201
if (someCondition)
    //trailing plus was missing from this line
    throw 'Could not set ' + last + ' of ' + (typeof root)
        ' to ' + (typeof obj);
return old;
我不知道它是否会识别浏览器整理的所有错误(所以我可能不会将此标记为答案),但它比 YUI 的缩小器为我做的要多得多(忽略所有这些例)。
此外,与 YUI 相比,编译器能够接受多个文件输入,因此可以为我提供每个文件的行号以查找错误,并且不会在关键字上出错/重新修改debugger关键字)。
希望它也能帮助你。