The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

too much CPU usage when doing className change ?!

But when i move my mouse over the rows altering the class thakes about 80% with IE(6) ans about 40% in Mozilla (1.1)...

what's that all about... it's not acceptable, so if anyone out there have a work around this, please contribute. I realy can't use anything else like this.style.backgroundColor, becouse i have to use seperated CSS file (multiple color themes)...

The CPU-usage comes from having to rerender sections of the page, if not the entire thing.

Changing colors, text-decorations, etc are typically fast operations. That is because nothing is reflowed. Which means the browser can keep the rendering of the rest of the page constant, while changing the look of the one element (which isn't changing in size).

Now, let's say we change font-size, font-weight, width, and height. The browser "knows" that these affect the box surrounding the element by changing its size. It has to rerender the element, it's children, and then all the element's parents until it can safely assume that the current element is not affected by the change in size.

If this is a small page, no problem. Modern browsers can typically render small pages fast (Mozilla and Opera faster than others though). Now, we take the time that takes, and consider a page many times larger. It seems to me that while it is still an O(n) operation (I could very well be wrong on this algorithm), the multiple of n that we ignore in algorithms increases.

If we could see the class you are changing from, and the class you are changing too, it may help a little.

Ok. Let me ask an important question. Are you concerned about the percentage figure itself? Or is there a visual performance hit? If you are just worried about the percentage, don't. Just quickly dragging a window around on my machine takes the CPU up to 100%, but it doesn't lag or cause performance issues, the CPU is just streching it's legs.