> From: Pops > This was the approach I was going, but didn't know the particulars. > Mikes native code is much faster (duh!).
I'm curious - did you actually benchmark it? I figure my native code should obviously be faster than jQuery code that uses the exact same approach, since it would just be doing the same thing with less overhead. But Erik's code uses a different technique entirely, so all bets are off. To paraphrase Knuth: "I have only proven it faster, I have not benchmarked it." :-) I've been surprised by this code in particular. A month or two ago, some of the folks on the list were talking about using CSS rules for animation, so I thought I'd see how this code would fare. It turned out to be much slower than the other techniques mentioned in the discussion. > But I wonder if he has a memory leak here: > > style.replaceChild( document.createTextNode(css), style.firstChild); > > But I don't know is replaceChild() literlally means replace > and deleted the old node. Ouch - you're right! I do have a bad memory leak in Firefox. Thanks for catching that! Actually I'm not sure if it is this code or something else in my test app - it has a lot of other stuff going on at the same time. Will investigate... -Mike