避免在 Chrome 开发者工具中单步执行 javascript 文件?

发布于 2024-12-11 01:11:52 字数 254 浏览 12 评论 0原文

我想知道,有没有办法从 Chrome 开发者工具调试器中省略 javascript 文件,这样它就会自动跳过对该脚本进行的任何函数调用?

我问这个问题是因为我的项目经常包含大型库,例如 jQuery。当我在调试时在 Chrome 开发人员工具中单步执行 javascript 时,每次在脚本中进行 jQuery 调用时都必须单步执行 jQuery 的 lib。

我最终不得不在每次调用 jQuery 对象后在一行设置断点。这是我发现跳过的唯一方法,而且非常烦人。

I am wondering, is there any way to omit a javascript file from Chrome Developer Tools debugger, so it will automatically skip over any function calls made to that script?

I ask because my projects often include large libraries such as jQuery. When I step through javascript in Chrome Developer Tools while debugging, I have to step through jQuery's lib every time I make a jQuery call in my script.

I end up having to set breakpoints one line after every call to the jQuery object. It's the only way I have found to skip past and it's very annoying.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

鯉魚旗 2024-12-18 01:11:52

更新2
在最新版本的 Chrome 中,此功能的用户流程得到了改进。请参考 https://developer.chrome.com/devtools/docs/blackboxing

<强>更新1
从 Chrome 版本 38 开始,您不再需要启用开发者工具实验。

以下详细信息仅用于历史记录

现在在 chrome 版本 30+ 中可以实现这一点。

  1. 从 chrome://flags/#enable-devtools-experiments 启用“启用开发者工具实验”。 (是的,您需要在输入 URL 的位置输入该内容)
  2. 重新启动 chrome
  3. 单击 Chrome 开发人员工具中的设置图标,
  4. 转到“实验”部分。请注意警告;),然后勾选启用框架调试支持。 (您可能还想尝试在调试时显示步入候选
  5. 现在,关闭 Chrome 开发工具并再次打开它。
  6. 单击 Chrome 开发者工具中的设置图标,
  7. 在常规部分中,您会发现“跳过具有特定名称的源”。勾选该选项并为您想要跳过的 JavaScript 文件名提供 regex

跳过某些 javascript 文件

来源:提示和技巧:在 Chrome 中调试时忽略库代码

UPDATE 2
There has been an improvement in user flow of this feature in latest versions of chrome. Please refer to https://developer.chrome.com/devtools/docs/blackboxing

UPDATE 1
Since Chrome version 38, you no longer have to enable Developer Tools experiments.

Below details are only for history

This is possible now in chrome version 30+.

  1. Enable "Enable Developer Tools experiments" from chrome://flags/#enable-devtools-experiments. (Yes, you need to type that where you type the URL)
  2. Relaunch chrome
  3. Click on settings icon in Chrome Developer Tools
  4. Go to Experiments section. Notice the WARNING ;) and then tick Enable frameworks debugging support. (You also might want to try Show step-in candidates while debugging)
  5. Now, close Chrome Dev Tools and again open it.
  6. Click on settings icon in Chrome Developer Tools
  7. In general section you will find "Skip stepping through sources with particular names". Tick that and provide regex for the javascript file names which you want to skip stepping into.

Skip stepping into certain javascript files

Source: Tips and Tricks: Ignoring library code while debugging in Chrome

爱的故事 2024-12-18 01:11:52

iSid 我想指出的是,从 Chrome 38 开始,您不再需要启用 devtools 实验。相反,如果您直接进入 F12 开发人员工具 ->设置->一般->来源,您将看到其中的最后一项是管理框架黑盒。好的部分是您可以在自己的线路上设置每个框架,或者您可以将通用的捕获所有模式放在一起,例如 (firebug|angular|knockout|jquery|bootstrap|modernizr|respond)

iSid I would like to point out that as of Chrome 38 you no longer need to enable the devtools experiments. Instead if you go straight to the F12 developer tools -> settings -> general -> sources you will see the last item in there is manage framework blackboxing. The good part is you can setup each framework on it's own line or you can throw together a generic catch all pattern like (firebug|angular|knockout|jquery|bootstrap|modernizr|respond)

荭秂 2024-12-18 01:11:52

版本 51 中的情况略有不同。

按 F12,然后按 F1。从左侧菜单中选择“黑盒”。

输入图像描述这里

Things are a little bit different in the version 51.

Press F12 then F1. Pick 'Blackboxing' from the menu on the left.

enter image description here

痴情换悲伤 2024-12-18 01:11:52

在 Chrome v68 下,在 .js 文件上调试时,使用左键单击黑盒脚本:

https:// /developer.chrome.com/devtools/docs/blackboxing

Under Chrome v68, while debugging on a .js file, use left click to blackbox script:

https://developer.chrome.com/devtools/docs/blackboxing

鸢与 2024-12-18 01:11:52

“Step Out”按钮可用于快速退出 JQuery 代码。

The "Step Out" button can be used to quickly get you out of the JQuery code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文