jQuery nextUntil sluggish

One of jQuery's latest traversal functions, nextUntil, adds enormous value for anyone using expand collapse functionality in their sites.

By allowing you to "select" all elements up until a given element, this short little block of code gives us just about everything we need for expand/collapse:

$('.expand-collapse').children('h3').click(function() {

But, if you find yourself using an older version of jQuery, say 1.4, you mind find that nextUntil function is a little on the "heavy" side in terms of execution time, especially in Internet Explorer 8.0 and prior.

The solution, simple, just upgrade jQuery. I've found the the latest 1.7 branch has greatly improved the execution time.

Why follow me on Twitter?

  • I tweet about new technologies, services or libraries I find interesting
  • Yeah, sometimes I'll post a pet-peeve or rant about something trivial
  • If I discover something that made my web development life easier, I share it
  • I'll shout out any handy tip that I think might be useful to other devs

Tagged , .

Updated: 2012-03-28

Phil LaNasa follow us in feedly