H. Ferrence
H. Ferrence

Reputation: 8116

How to analyze and diagnose javascript long run times

I have a fairly extensive javascript that I can load in my Chrome (latest stable) and in IE11.

The load icon spins but the script eventually loads on my machine in both browsers.

I have 2 other people trying to load the page that contains the javascript in IE11 and they both cannot get the page to load. The loader icon spins forever and when they mouse over the refresh icon a flyout states "long running script"

How can I analyze my javascript to identify how and where the script is taking forever to load?

Upvotes: 1

Views: 785

Answers (1)

J.D. Pace
J.D. Pace

Reputation: 616

Chrome's Developer Tools (F12) can profile your code. This will give you a lot of information -- possibly a lot of noise -- but it will identify two things for sure 1) functions where a lot of time is spent, and 2) functions that are called often.

This is the first place I'd start: turn on the profiler and reload the page.

If that doesn't give you a good place to start, look into the Chrome Timeline and console.timeStamp( 'Some Note' ). After you have started recording a timing session, every time the code encounters "console.timeStamp", it will annotate the timeline allowing you to estimate elapsed time between one or more points in your execution. See here: https://developers.google.com/chrome-developer-tools/docs/console#measuring_how_long_something_takes

Upvotes: 4

Related Questions