Safari Inspector to Easily See Function Call Stack

When trying to track down where some Javascript code is getting executed, it’s useful to see a function call stack. While many browser inspectors can give you this information, I have found Safari’s inspector to be the easiest to use for this particular purpose. In the screenshot below, you’ll see that I set a breakpoint on line 8 where the “write” function is defined. When you load your page, you’ll see a call stack box on the left in the Safari inspector showing all of the functions that were called before the “write” function was called. Clicking on each function shows you the section of code in its respective file. In this case, an anonymous function in the “search” file (search.html) on line 259 called another anonymous function in the “search” file on line 261 which then called another anonymous function in the jsapi file (jsapi.js) on line 93 which called another anonymous function in the jsapi file on line 244 which called function “d” in jsapi on line 143 which then finally called the “write” function in main.js on line 8 where I set the breakpoint.

safari-inspector