How to debug dynamically loaded JavaScript?

I have a bit of code that loads a script:

 

var script_func = new Function('ARGS','kbn','dateMath','_','moment','window','document','$','jQuery', 'services', result.data);
var script_result = script_func($routeParams, kbn, dateMath, _ , moment, window, document, $, $, services);

When this gets run, it dynamically loads a script `scripted.js` - are there any ways for me to debug dynamic JS? I can't put breakpoints in the file when it loads in the debugger - can I somehow map this to the actual script file in my project?

This question is extremely similar to https://stackoverflow.com/questions/9092125/how-to-debug-dynamically-loaded-javascript-with-jquery-in-the-browsers-debugg -- however, I want to stay in WebStorm if possible.

0
3 comments

you can locate the loaded script in debugger Scripts tab (it normally shows all scripts loaded in VM), open it in editor and set breakpoints

0
Avatar
Permanently deleted user

This let's me see the file that's being loaded, but the breakpoints aren't active (since it's being loaded I guess) - I'd like to start the app, set breakpoints in the VM script, and then continue. Is that possible?

0

No, it's not possible:(

0

Please sign in to leave a comment.