Reputation: 174
Is there a way to debug the page with browser console or firebug to know how many times a specific Javascript function is called while loading the page ?
Upvotes: 1
Views: 63
Reputation: 7214
As @SamGreenhalgh pointed out, in Google Chrome, you can simply open the Developer Tools ([Ctrl]+[Shift]+J
), find your script in Sources tab, and add
console.count('some label');
right into the body of the function you wish to observe. This will print out
some label: {N}
into the console each time console.count
is called at that point with that label (see documentation).
Upvotes: 1
Reputation: 1075537
You can set a breakpoint on the function, reload the page, and count how many times you have to press the Continue button.
In the dev tools of most browsers (and in Firebug), you'd do that something like this:
Go to the page
Open the dev tools (via menus, or press F12 on most browsers, etc.)
Navigate to the "Source" pane (the name varies, but it's usually something like that)
Find the function in the scripts. (Chrome's dev tools have a great feature: Ctrl+Shift+F does a search through all loaded scripts.)
Click the gutter to the left of the function to set a breakpoint
Then reload and count. I'm not aware of an automated way to do it.
Upvotes: 1