Javascript 我可以告诉 Chrome 脚本调试器忽略 jquery.js 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7126822/
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-08-24 00:57:43  来源:igfitidea点击:

Can I tell the Chrome script debugger to ignore jquery.js?

javascriptgoogle-chrome-devtools

提问by Josh Schultz

Is there a way to tell the Chrome debugger (or maybe Firebug?) to not break within certain files? To assume they're not broken, essentially? This seems like something they might build in.

有没有办法告诉 Chrome 调试器(或者 Firebug?)不要在某些文件中中断?假设它们没有损坏,基本上?这似乎是他们可能内置的东西。

采纳答案by Nirmal Patel

Blackboxing JS files is now possible in Firefox https://developer.mozilla.org/en-US/docs/Tools/Debugger

现在可以在 Firefox https://developer.mozilla.org/en-US/docs/Tools/Debugger 中使用Blackboxing JS 文件

And in Chrome Canary using Experimental Dev tools. http://www.divshot.com/blog/tips-and-tricks/ignoring-library-code-while-debugging-in-chrome/

在 Chrome Canary 中使用实验开发工具。 http://www.divshot.com/blog/tips-and-tricks/ignoring-library-code-while-debugging-in-chrome/

Update. In Chrome v.75there is a separabe tab for blackboxing.

更新。在 Chrome v.75 中有一个用于 blackboxing的 separabe选项卡

Above works in stable Chrome build as well now.

以上现在也适用于稳定的 Chrome 版本。

回答by The_Black_Smurf

The latest version of Chrome has implemented a new blackbox featurethat does exactly what you are looking for. Basically, when you set the blackbox option on a given file, it will prevent Chrome debugger from breaking into that file.

最新版本的 Chrome 实现了一个新的黑匣子功能,可以完全满足您的需求。基本上,当您在给定文件上设置 blackbox 选项时,它将阻止 Chrome 调试器闯入该文件。

This feature is built-in and it can be set with the context menu of the file (right click). It will also work if Chrome debugger is set for stopping on all exceptions.

此功能是内置的,可以使用文件的上下文菜单(右键单击)进行设置。如果 Chrome 调试器设置为在所有异常时停止,它也将起作用。

回答by jfriend00

If the issue you're having is that the Chrome debugger is stopping on all exceptions, even the ones inside of jQuery, then you may need to tell Chrome to only pause on uncaught exceptions, not all exceptions. When in the Script panel in the debugger, there is an icon in the lower left corner of the window that controls this.

如果您遇到的问题是 Chrome 调试器在所有异常上停止,即使是 jQuery 内部的异常,那么您可能需要告诉 Chrome 仅在未捕获的异常上暂停,而不是所有异常。当在调试器的脚本面板中时,窗口左下角有一个图标来控制它。

回答by sMyles

In Chrome, open Developer Tools, then goto Settings, and you will see the Blackboxtab:

在 Chrome 中,打开 Developer Tools,然后转到 Settings,您将看到Blackbox选项卡:

Chrome Blackbox

铬黑盒

In FireFox it's even easier, just click the Eye at the bottom of the file:

在 FireFox 中更简单,只需单击文件底部的眼睛:

FireFox Blackbox

火狐黑匣子

回答by Mahmoud Asadi

  1. Go to developer tools setting and click on Balckboxing tab on the left panel.
  2. Then click on the Add pattern button and type jquery.js
  3. Close and reopen developer tools, now its skipped!
  1. 转到开发人员工具设置,然后单击左侧面板上的 Balckboxing 选项卡。
  2. 然后单击添加模式按钮并输入 jquery.js
  3. 关闭并重新打开开发人员工具,现在已跳过!

回答by Kelly Sutton

If the debugger is blowing up somewhere in the jQuery files, you could potentially wrap the suspect calls in a try/catch and then throw an error in your own catch. That way, you can isolate exactly where your're going wrong.

如果调试器在 jQuery 文件中的某处崩溃,您可能会将可疑调用包装在 try/catch 中,然后在您自己的catch. 这样,您就可以准确地隔离出您出错的地方。

I would be more inclined to do stack traces to see why my code is blowing up, e.g. invalid JSON, than to try gloss over it.

我更倾向于进行堆栈跟踪以了解为什么我的代码会爆炸,例如无效的 JSON,而不是尝试掩盖它。