2

Our web project has a very big js file which actually is an aggregation of modified legacy 3rd party libraries.

Only about 5-10% of code from this file is used in the application. So as an attempt to optimize js size I made a folllowing plan:

  1. Make a js function call logger (like it was done here)
  2. Run all cases of the application
  3. Check which methods where called and mark their lines of code (coverage).

In order to do (3) I need to know which lines of code where included in called method. Then I could use it to format JS out as html and highlight used code. But question is how to know what are this lines?

I can exploit console.trace method but it is giving only entry line, not exit line (and even it do, that would be pointless, because exit line is not always end of method). So it looks like I need to get code properties (like code start and code end) of certain function.

How to get start and end line of certain JS function?

Update: I've found a lib which can do almost same thing (istanbul.js), but still welcome answers to the question above.

Community
  • 1
  • 1
setec
  • 15,506
  • 3
  • 36
  • 51

0 Answers0