How to generate call-graphs for given javascript?

beatak picture beatak · Apr 17, 2012 · Viewed 15.9k times · Source

I have seen "https://stackoverflow.com/questions/1385335/how-to-generate-function-call-graphs-for-javascript", and tried it. It works well, if you want to get an abstract syntax tree.

Unfortunately Closure Compiler only seems to offer --print_tree, --print_ast and --print_pass_graph. None of them are useful for me.

I want to see a chart of which function calls which other functions.

Answer

scottmrogowski picture scottmrogowski · Jun 6, 2013

code2flow does exactly this. Full disclosure, I started this project

To run

$ code2flow source1.js source2.js -o out.gv

Then, open out.gv with graphviz

Edit: For now, this project is unmaintained. I would suggest trying out a different solution before using code2flow.