OZONE Asylum
Forums
DHTML/Javascript
JS animation performance: reflow/redraw cost, CPU use?
This page's ID:
30631
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
I don't know whether this will increase speed a lot... But the bottleneck seems to lie in [i]this.move[/i]. Here are 4 (random?) ideas, which just happen to pop into my head. 1. Cache the images' style. [code] this.o.style.left = ... -> this.S.left = ... [/code] 2. Call this.move() directly, not through this.animate() 3. Cache this.flakes[i] (in this.snow()): [code] for (var i=this.flakes.length-1; i>0; i--) { if (this.flakes[i].active == 1) { this.flakes[i].animate(); active++; } else if (this.flakes[i].active == 0) { used++; } else { waiting++; } } -> for (var f, i=0; f = this.flakes[i++];) { if (f.active == 1) { f.animate(); active++; } else if (f.active == 0) { used++; } else { waiting++; } } [/code] 4: [code] setInterval("snowStorm.snow()",75) -> setInterval(snowStorm.snow,75) [/code] Just out of curiosity (and because I am tired...), why are you calling one every 25ms and one every 75ms fpr windows 9x? Increasing the timeout of 20ms just a little bit should not affect the snow effect that much, should it? It would certainly decrease CPU load. Probably a lot more than any of the above ideas! Cheers, kwei _______________ http://weibell.de/ [small](Edited by [url=http://www.ozoneasylum.com/user/6831]kwei[/url] on 11-02-2008 00:55)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »