Using Chrome's Developer Tools - to find out where a javascript function is being called

7

2

The thing is, I have this big website with lots of JavaScript files and stuff. And I am trying to change the jQuery UI accordion plugin's settings so that it wouldn't do auto height of the wrapper based on it's contents. I am trying to figure out where this accordion is being called. But it's giving me headache as there are lots of JavaScript files. Tried to search for "accordion" keyword. But it seems to be not finding it either.

Since this would be a waste of time, I was thinking whether there is anyway that we could debug the JavaScript function calls, so that it would output to the console, the filename and line number for each function calls.

I tried to play with the Developer Tools to see if there is a facility like that. But was not successful. So thought of posting it here and could see if there is some other way or tools to do this.

Akhilesh B Chandran

Posted 2013-12-30T10:16:21.607

Reputation: 205

Answers

12

Put console.trace() in the function and check console. It will print where a call is coming from.

Jishnu

Posted 2013-12-30T10:16:21.607

Reputation: 146

Been looking for this answer for a long time, thank you! – John Miller – 2014-09-12T17:33:49.037

0

That is not the only way though: to find where a specific function is being called from you can add a undefined variable to the function and in the chrome console it will display where the error is comming from, so if i want to find the function renderLayer, i add console.log(PurpusefullyundefinedVariable); and this is the output:The Output

cuddlybunion341

Posted 2013-12-30T10:16:21.607

Reputation: 1