Saw you had no responses so here's a couple of suggestions...

An easy performance booster is to use the second param in $() to set a
context for the search. Eg: $("DIV.myClass", myParentElement). Perhaps this
is what you meant when you mentioned 'getting a parent element' ?

Chaining methods is helpful so you can avoid re-querying. If you need to put
other code in betwen method calls then reusing the same JQuery object by
putting it into a variable beforehand is worth while to save requerying.

If you're going to do several queries inside the same parent element(s) then
a combination of the above will be a big help.

Not sure what experience you have. You may have already tried these
approaches. Worth a try if not. Someone more involved in the development may
be able to offer some more in depth performance tips.

Cheers

George


Raziel Alvarez wrote:
> 
> Hi. I'm building a highly dynamic application based using jQuery
> extensively. I have a set of templates with predefined markup, which is
> retrieved and modified using jQuery CSS queries. However, as the markup
> size
> increases the queries are becoming considerably slow. I've tested some
> different ways of rewriting my queries (retrieving the elements by id,
> searching by name or any other attribute under a specific context, getting
> a
> parent element and traversing the DOM using operations like children(),
> etc.) but I haven't discovered a best practice so I can improve the
> performance consistently.
> 
> I also tried to use XPath queries, but they actually didn't work (even the
> simplest ones) and I think they're built as CSS queries anyway.
> 
> Can anybody point me in the right direction to write performant code with
> jQuery? I know it depends on my markup and other factors, but I wonder if
> there's a set of best practices in order to get the most of the library.
> 
> Thanks,
> 
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Performance-question-tf2398816.html#a6697355
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to