JavaScript Optimizations

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

JavaScript Optimizations

Post by Chris Corbyn »

Hiya!

Often lately when I write JS that does something DHTML-ish (i.e. something that animates) I find it runs very slowly on what I would call an average PC (1.5GHz CPU, 512MB RAM). Even slower if testing it in IE.

Does anyone know any good links/resources that deal specifically with optimizing JavaScript code that does fancy things like animations?

I also occassionally find IE hanging before deciding to process JS even on fairly basic DHTML pages (using DOM.... does IE recurse the whole DOM tree before executing functions etc or something?).

Cheers,

d11
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I've found that it can often have to do with memory allocations being issued and removed. The garbage collection routines seem to be rather poorly implemented in many browsers.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

feyd wrote:I've found that it can often have to do with memory allocations being issued and removed. The garbage collection routines seem to be rather poorly implemented in many browsers.
This is my thinking too. A particular page declares an array. That array then has anywhere between zero and 365 items added to it on page load (once-only) (can you guess what it's for? :P).

Now that in itself should not be an issue in most languages. For some reason however, once that array has been filled something as simple as a rollover will have a noticable delay in Internet Explorer.... rather odd :( It's not specific to just that script neither, I tend to find this a lot when working with arrays in JS.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Not particularly optimization, but good to know nevertheless: http://del.icio.us/bweirdan/javascript+bug
Post Reply