2

I've tried debugging minimalized js code that is not mine.
But it's too hard to debug using chrome's dynamic analyzer tool.
Because all of code is in one line by code minimalizer.
So i can't analyze code's dynamic flow.

What should i do for dynamic analyzing?

crazy_rudy
  • 157
  • 2
  • 9
  • 5
    Try clicking the `{}` icon. – John Dvorak Mar 18 '13 at 07:38
  • @JanDvorak +1 It's a good idea to test it but it doesn't seem to always work. – Denys Séguret Mar 18 '13 at 07:42
  • @dystroy sometimes it takes quite long (a few seconds in case of jQuery), and does not split comma-separated code. I haven't encountered a case where it failed to indent reasonably. – John Dvorak Mar 18 '13 at 07:45
  • 2
    You could try a beautifier like [JSBeautifier](http://jsbeautifier.org/) – Moritz Roessler Mar 18 '13 at 07:45
  • @C5H8NNaO4 And how do you use that in a debugger (assuming you can't change the served code) ? – Denys Séguret Mar 18 '13 at 07:58
  • @dystroy I just copy the function that i'm currently in, beautify it, then just read it, i know.. its not a super duper solution, but in my (personal) opinion, i find it at least easier to debug that reading a one-liner in the debug console. But thats how i do it atm, would be interested in a better solution too – Moritz Roessler Mar 18 '13 at 08:04

1 Answers1

0

Debugging "minned" code can be tricky...I would suggest employing the following "reverse engineering" practices (other than contacting the code's owner and asking for a non-minned version...):

  • Add new lines after each semi-colon (";") to the code, so that it will be a little easier to read and will print out the correct line number in the console if their is an exception or error of some sort.
  • After adding new-lines, run the code through a service like http://jsbeautifier.org/ to make it a bit more readable.
  • Try adding "console.log(obj)" calls to the code. This allows "printing" objects to the console for inspection.
BlueYoshi
  • 1,534
  • 12
  • 18