Performance of selecting elements

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Performance of selecting elements

Steve Owsinski
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
[hidden email]
http://jquery.com/discuss/
Reply | Threaded
Open this post in threaded view
|

Re: Performance of selecting elements

malsup
I can't answer your question, Steve, but I know this has been looked
at by others. Does any one know if Mike Geary's performance
improvements made it into the dev trunk yet?

_______________________________________________
jQuery mailing list
[hidden email]
http://jquery.com/discuss/
Reply | Threaded
Open this post in threaded view
|

Re: Performance of selecting elements

Andre  Lewis
Steve, I just alias $id=document.getElementById, and use that when I need do a much of basic DOM manipulations by ID, or perform something which doesn't require the full jQuery mojo.

Andre

On 6/7/06, Mike Alsup <[hidden email]> wrote:
I can't answer your question, Steve, but I know this has been looked
at by others. Does any one know if Mike Geary's performance
improvements made it into the dev trunk yet?

_______________________________________________
jQuery mailing list
[hidden email]
http://jquery.com/discuss/



--
[hidden email]
www.earthcode.com : Web 2.0 Tech/Rails/JavaScript/AJAX
_______________________________________________
jQuery mailing list
[hidden email]
http://jquery.com/discuss/