1

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.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
macmac
  • 11
  • 1
  • 2
  • Why do you want to know “which js page is loaded from what other js pages” (if you mean .js files by that)? It sounds like you have some kind of problem. Do you want to know *if* a certain script is already loaded or not? – Marcel Korpel Jun 22 '10 at 23:20

3 Answers3

1

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

Community
  • 1
  • 1
diyism
  • 12,477
  • 5
  • 46
  • 46
1

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.

Luca Matteis
  • 29,161
  • 19
  • 114
  • 169
1

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

Olivvv
  • 1,140
  • 1
  • 13
  • 37
  • you can see "javascript triggers" in the dynatrace timeline. Right click on the timeline and choose options. – Olivvv Feb 10 '11 at 13:43