How to detect the source(file) of a function through the developer console?

Asked

Viewed 62 times

2

I don’t know if this question fits the OS standards/scope, but here it goes:

It is possible to detect the origin(file) of a javascript function through the developer console in the current browser?

For example:

I have a javascript file with the function:

function teste(){
}

Entering console mode if you start writing te note that there is a function teste, but right now I don’t know where it comes from.

In my view the only method for me to ascertain its origin would be to check all requests made to the server by files. js and do a search for the string teste() in each of those files.

But if the site has several javascript files it is difficult to determine the correct file, not to mention if the script is not with the code obfuscated which will complicate things even more.

Which begs the question:

Is there a more viable method for me to detect the origin of this function?

For example if this function was a event listener one-click on a button I could easily detect its origin inspected the button element.

  • You need to find out which file(file) the function is declared in?

  • Yes exactly.

1 answer

1


In the Chrome, has the option to go to the function setting in the console itself.

inserir a descrição da imagem aqui


Already in the firefox I could not find a way to go to the function declaration through the console, but we can search for the function name in all files.

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.