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.
Please sign in to leave a comment.
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
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?
No, it's not possible:(