javascript - 检测链接和未使用的文件以及未使用的 JavaScript

标签 javascript jquery

我刚刚完成了我的网站,该网站是我两年前开始创建的。我总是尝试新事物,有时包括添加不同的框架或其他外部 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/

相关文章:

javascript - 无法设置溢出 : hidden; on a div

javascript - Onclick 检查输入字段是否为空,然后将文本 onclick 更改为密码

javascript - jquery next() 函数无法正常工作

jquery - Bootstrap 进度条 : add to the css: width value, 全部在 coffeescript/jQuery 中

javascript - 带有 Ajax 的浏览器 "Busy State"

javascript - 为什么 jQuery 的 $.type() 定义为返回 "object"而不是 "error"用于原生 ECMAScript 错误对象?

javascript - Angular2 setinterval 在 dom 更改时被阻止

javascript - 菜单项 onclick 在悬停事件上调用多 css

除非我刷新,否则 jQuery Mobile 中的 JavaScript 无法正常工作

javascript - 我想要一个按钮来使用 jquery/JavaScript 触发链接