Reputation: 99
Is there any way to detect if Javascript code is taking more time to execute than it should? I don't want to run code, then determine the time it took, I want to determine if actively running code is going slower than it should, and stop that whole script.
Upvotes: 1
Views: 4853
Reputation: 1145
I really liked Nicholas Zakas's presentation titled Speed Up Your JavaScript. Some points to mention from it:
This information is a couple years old, but there are a lot of good practices in the presentation.
Upvotes: 3
Reputation: 8886
The YSlow add-on is the best solution to know why your website is slow.
There are many issues which could be the reason for slowness.
Combining many jQuery to one could help you increasing your performance.
Also you can put the script at the bottom of your page and CSS at top.
Upvotes: 2
Reputation: 36446
There's no concrete measure of how long a script "should" run. If you want to find where your code is slowest though, I would use a profiler.
FireBug has one and so do most other developer tools.
Upvotes: 2