最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Javascript optimization - Is there an easier way to speed up Javascript? - Stack Overflow

programmeradmin1浏览0评论

I wrote a hefty script in JS and I want to optimize it to run faster, but going through function by function and performing a "speed test" is taking too long. Anyone know of a better way? I've heard you can use firebug, but I haven't found any helpful links of how to go about that..

The page I'm optimizing is here: .html

I'm specifically trying to optimize the flanvas.js which is here: .js

Any direction of where to go from is very helpful. Thanks!

I wrote a hefty script in JS and I want to optimize it to run faster, but going through function by function and performing a "speed test" is taking too long. Anyone know of a better way? I've heard you can use firebug, but I haven't found any helpful links of how to go about that..

The page I'm optimizing is here: http://flanvas./development/flanvas/examples/custom-class.html

I'm specifically trying to optimize the flanvas.js which is here: http://flanvas./development/flanvas/flanvas.js

Any direction of where to go from is very helpful. Thanks!

Share Improve this question asked Jan 13, 2011 at 4:17 JacksonkrJacksonkr 32.2k42 gold badges189 silver badges289 bronze badges 1
  • possible duplicate of What is the best way to profile javascript execution? – Phrogz Commented Jan 13, 2011 at 4:23
Add a ment  | 

3 Answers 3

Reset to default 6

Use FireBug, or the Developer Tools in Safari or Chrome. In Safari/Chrome, go to the "Profiles" tab, click the "Enable Profiling" button, and hit the 'record' button. After you've done enough testing, hit it again to capture the profile.

You'll get a wonderful list breaking down your functions by the time they took, the time other functions that they called took, and multiple ways to sort it.

Rather than walk you through this, I'll give you some of the Google searches you should have done before asking this question:

  • http://www.google./search?q=profiling+javascript+firebug
  • http://www.google./search?q=profiling+javascript+chrome

You want to do profiling first for your javascript code to find which part of the code is the slowest. Of course, the main tool for that is firebug. Firebug is a very great tool for profiling.

You may also want to see this question for some more help: What is the best way to profile javascript execution?

If you are using Firefox, firebug is a good tool, it can also give you some basic ideas on how to speed up javascript.

More at http://getfirebug./whatisfirebug

You can download it as JS code, and add it to your file if you are using other browser.

Still, there are other tools around, if that doesn't help... but it is a good start

发布评论

评论列表(0)

  1. 暂无评论