There’s a function in the external JavaScript for a website (not my own) and I want to know where it’s used, since apparently it is never run. I’ve tried every action on the website and nothing makes it run. The only way I can think of is reviewing event listeners on every element until I find it but that would take ages. Is there something in the inspect element menu where I can look up where a piece of JavaScript code is running, sort of like the inverse of looking at event listeners on an element, or something equivalent I can do using other software? If it helps, the JavaScript file is ran just one script tag in the HTML.
The website is a relatively small image editor. I’ve done everything I can on it and the code isn’t running, I’ve tried looking for ways I can view references to the function in the inspect menu too, including using console.trace(), but I don’t think that helps in my case since the code isn’t run, unless I’m misunderstanding how it works.
Edit: clarifications that the function I’m interested in doesn’t run by any of my actions, fluff removed.
4
So first, I have to say that what you are asking to do is not technically possible. Because you can do something like global["t" + "e" + "s" + "t"]()
to call a function in the global scope called “test” you can’t be certain that you will find every reference. And there is no tool that could find every reference to the function.
That said, I would recommend using the dev tools debugger in Chrome or Firefox, go to the debugger part, and use the search. If no results come up for the name of the function in question, it is probably unused code.
I’m curious why you are doing this though. It is a very strange thing to want to do.