[jQuery] Performance of selecting elements
Hi everyone,
I have a question regarding the performance of jQuery when selecting
elements. This originated from some simple benchmarks that I wrote to
gauge performance vs. Prototype. For example, I tested the following
loops, the first with jQuery and the second with Prototype.
for (var i=0; i<100; i++) { $('#contest').css('color','red'); } //
jQuery
for (var i=0; i<100; i++) { e = $('contest'); e.style.color='red'; }
// Prototype
The jQuery version took significantly longer than the prototype version
(which felt instant). Now, I fully realize that I am not using the full
potential of jQuery, and the code I wrote is essentially a DOM wrapper
(so Prototype would instinctively be faster). I love jQuery and the
philosophy and development process, but I'm worried about using it in
an environment where I am doing a ton of basic DOM manipulations... has
anyone experienced this kind of performance problem, and are there
workarounds? I tried removing plugins, simplifying the $.Select
function, stripping down the self = {...} code in the $() function,
etc... I'd really love to find a solution where I can use jQuery.
Many thanks,
Steve
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/