1

In complicated system, how can I get a list of all the JavaScript files that has been fired during button click or click to input field?

Can I do it with chrome dev-tools or are there any other solutions? If I can do it with chrome dev-tools then how?

Problem that I am facing: I am trying to find file what contains method which I can intercept to add my custom validation before button click redirects to another page? File names are useful to me because the system is following clean code rules.

UPDATE: I found this tutorial, but none of provided solution seems to work (I am certain that breakpoints are not working). The Visual Event extension suggested by @Carles Alcove in referred post, lead me to knockout.js file. In that file I added console.trace() function (second image is the result) as suggested by @guest271314. First image is when I inspected the button with dev-tools as suggested by @user3297291

enter image description here enter image description here

Community
  • 1
  • 1
user3748173
  • 215
  • 2
  • 9

2 Answers2

1

You can include console.trace(), console.profile() and console.profileEnd() within click event handler, review line numbers of files at console and Profiles tab at DevTools

guest271314
  • 1
  • 15
  • 104
  • 177
  • The `Profiles` tab helped me a lot (thanks for pointing that out). I could see some of the files that where fired - only issue is that it is not quite exact. It would be perfect if the profiler could be set to start recording when event is fired. – user3748173 Feb 06 '17 at 14:18
0

You can check an overview of event listeners attached to an element in the developer tools by doing:

  • Right mouse button on an element
  • Inspect element in context menu
  • Click Event Listeners tab in the right panel of the dev. tools
  • Check for mouseup or click events.

enter image description here

You'll see the attached methods and their file names. I'm not sure if this works for every kind of event listener (e.g. if the event is bound to a parent element), but it's a quick way to predict what might be called.

user3297291
  • 22,592
  • 4
  • 29
  • 45