macmac
macmac

Reputation: 11

How do I get a JavaScript call trace of a webpage?

Can someone tell me how I can get a call trace between different JavaScripts?

Suppose I have an HTML page that loads some JavaScript files, which in turn may load other JavaScript files from the server. Is there a way that I can trace which JavaScript page is loaded from what other JavaScript pages?

I've used Google Chrome speed tracer extension, and can get the event trace of the browser, normally JavaScript evaluation events were registered, but not all of the registered events have the attribute specifying what other script triggered the evaluation.

I've also used Firebug, but it seems it's more useful in debugging JavaScript instead of what I want.


Let's say an HTML file has a tag <script type="text/javascript" src="A.js"> And in A.js, it invokes a function defined in B.js. In this function, another function in C.js is called and thus C.js will be downloaded (suppose C.js hasn't been downloaded and loaded yet).

I just want to know if it is possible to find this "call trace" of A.js-->B.js-->C.js, and also the "downloading sequence" of A.js, B.js and C.js if initially none of them was downloaded.

Yes, it is possible to investigate this by going through the code manually, but I'm trying to understand the relationships of .js files of a fairly large website, which may contain too many JavaScript files to be handled manually.

Thanks. I hope this may clarify the question.

Upvotes: 1

Views: 5444

Answers (3)

diyism
diyism

Reputation: 12935

1.functionLogger.addLoggingToNamespace(window); refer to How to get Javascript Function Calls/Trace at Runtime

2.stacktrace.js in http://stacktracejs.com/

3.Enable Chrome Logging(http://www.chromium.org/for-testers/enable-logging) and filter the log file you get for lines with 'CONSOLE(\d+)'.

Or give a try to diyism_trace_for_javascript.htm:

https://code.google.com/p/diyism-trace/downloads/list

Upvotes: 1

Olivvv
Olivvv

Reputation: 1200

use dynatrace : http://ajax.dynatrace.com/pages/download/download.aspx

Upvotes: 1

Luca Matteis
Luca Matteis

Reputation: 29267

What do you mean by 'load other javascript files'?

The standard way of loading a JavaScript file is to add the <script src="file.js"></script> tag to the HTML page.

The fastest way to understand what files are being loaded is to go through the code and look for anything that does some sort of <script> tag creation.

Upvotes: 1

Related Questions