javascript 仅禁用浏览器中的某些 js 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20747352/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 19:12:06  来源:igfitidea点击:

Disable only certain js files in a browser

javascriptgoogle-chromefirefoxgoogle-chrome-devtools

提问by Dmitry

I'm trying to diagnose an issue with a web app that uses multiple Javascript files. One of the scripts modifies DOM by injecting a new element into it. My idea is that I would disable js files one by one until I find the one that causes the DOM modification. Is there a way in a browser to disable only certain js files? I would prefer a solution in Google Chrome (if its not possible then in Firefox or IE11)

我正在尝试诊断使用多个 Javascript 文件的 Web 应用程序的问题。其中一个脚本通过向其中注入新元素来修改 DOM。我的想法是我会一个一个禁用js文件,直到找到导致DOM修改的那个。有没有办法在浏览器中仅禁用某些 js 文件?我更喜欢 Google Chrome 中的解决方案(如果不可能,则在 Firefox 或 IE11 中)

回答by Kayce Basques

Try DOM Change Breakpoints. Whenever some JS modifies your DOM, you pause on the exact line of code that caused the change.

尝试DOM 更改断点。每当某些 JS 修改您的 DOM 时,您就会停在导致更改的确切代码行上。

And yes, it is possible to disable JS files. See Block Requests. DevTools blocks the request for the JS file, therefore it never runs. Although in this particular situation, DOM Change Breakpoints will probably help you diagnose the problem faster.

是的,可以禁用 JS 文件。请参阅阻止请求。DevTools 会阻止对 JS 文件的请求,因此它永远不会运行。尽管在这种特殊情况下,DOM 更改断点可能会帮助您更快地诊断问题。

回答by Tirtha

Probably you should use an external tool like fiddler, or use Browser Plugins. Firefox and Chrome both has plugins that can do this.

可能你应该使用像 fiddler 这样的外部工具,或者使用浏览器插件。Firefox 和 Chrome 都有可以做到这一点的插件。