Debugging dynamically added javascript files

浪子不回头ぞ 提交于 2019-12-04 02:44:27

You can add the debugger; statement in your dynamic scripts where you want to set the breakpoint. This will make chrome stop on it like a regular breakpoint if the execution thread reaches the statement while the developper tools UI is opened.

You can also start your script with that, so your script appears in the debugger, and you can after that manually set a breakpoint where you want.

Check out sourceURL which is a way to indicate to the DevTools that should treat eval'd strings as real files. It does exactly what you're looking for.

At the end of the string to be evaled, leave comment of this form:

//# sourceURL=app/js/myapp.js

From there, Chrome DevTools (and Firebug) will treat this as a "real file".

Much more explanation here and HTML5 Rocks has an article and a sourceURL demo.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!