2

I just spent a long time trying to figure out how to use source maps to get eval'd javascript code to show up in the debugger where I could put break points on it and stuff. I kept seeing hints that it was possible, but most of what I read had to do with source mapping minified code or CoffeeScript, and generally it all seemed impossibly complicated. But then I stumbled on the answer, which was ridiculously easy, and I'll answer my own question below.

durron597
  • 31,968
  • 17
  • 99
  • 158
Sigfried
  • 2,943
  • 3
  • 31
  • 43

1 Answers1

1

Just put this at the end of the eval block:

//@ sourceURL=foo.js

In the Chrome sources panel, foo.js now shows up under '(no domain)'.

Sigfried
  • 2,943
  • 3
  • 31
  • 43
  • Oh, and I got it from: https://blog.getfirebug.com/2009/08/11/give-your-eval-a-name-with-sourceurl/ – Sigfried Mar 25 '15 at 11:05
  • And, after failing to find the answer in stackoverflow by searching for question keywords, I did find it by searching for the actual answer: http://stackoverflow.com/questions/13129904/how-do-i-debug-javascript-which-was-loaded-via-ajax-specifically-jquery. So, I'll leave my version because maybe it will be easier for people to find. – Sigfried Mar 25 '15 at 12:07