我刚刚完成了我的网站,该网站是我两年前开始创建的。我总是尝试新事物,有时包括添加不同的框架或其他外部 JS 文件。
现在我不知道哪些 JS 的链接文件/行没有被使用。有没有一个工具可以检测这些文件和代码行?这会节省我很多时间。
最佳答案
This回复优惠Google's Closure Compiler在缩小和连接 JavaScript 代码的过程中,它可以删除“死代码”。
引用自the documentation对于编译级别:
Compilation with ADVANCED_OPTIMIZATIONS removes code that is provably unreachable. This is especially useful in combination with large libraries. If you use only a few functions from a large library file, the compiler can remove everything except those functions from its output.
另请参阅this answer其中包含有关 Google 闭包编译器的更多信息。
关于javascript - 检测链接和未使用的文件以及未使用的 JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13174988/