Dave, I tried that, but $("div.recentposts a:first").each(function(i){
seems to only find the first div.recentposts a instead of the first a in
each div.recentposts.
On 12/8/06, Dave Methvin <[EMAIL PROTECTED]> wrote:
> I've got a script that I could use some help fine-tuning and optimizing,
> and I'm hoping you all can help. The script is used to collapse forum
> topics and can be seen in place at
> http://gretschpages.com/forum/modern-gretsch-guitars/
>
> ShowLatest() is a helper function that moves the first item up in the
tree
> so it's still visible after the collapse.
Ouch, that's way too slow. No matter what, I think there are too many
posts
there. You need some way to page through them and avoid loading them all
at
once.
There seems to be a lot of repeated code sequences there that could be
reduced but I just took a quick shot at showLatest:
function showLatest() {
$("div.recentposts a:first").each(function(i){
$(this.parentNode.parentNode.parentNode.previousSibling).append(
$(this).clone().html(" »").addClass("lastpost")
);
});
}
A bare selector of ".recentposts" is very expensive, it has to go through
every node in the document which is a ton on a page this big. Try to
always
prefix the class name by a tag type to limit the search. I consolidated
the
search for the link into the same selector and chained everything. Instead
of parent() and prev() I just used parentNode and previousSibling, I think
that's a safe transformation given the HTML but you could back them out.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/