up to jQuery 1.2.6 that's how the selector engine worked (from the top down/left to right). The approach used in Sizzle (bottom up/right to left) has both benefits and downsides - it can be much faster on large DOMs and some situations, but slower on short queries. I'm sure someone can explain that in better detail.
Anyway, in modern browsers most of the work is being delegated to the native querySelectorAll function, as so selector performance will become more of a browser makers' concern. - ricardo On Feb 23, 1:08 pm, Peter Bengtsson <pete...@gmail.com> wrote: > I watched the John Resig presentation too and learned that CSS > selectors always work from right to left. > That would mean that doing this:: > > $('#foo p') > > Would extract all <p> tags and from that list subselect those who > belong to #foo. Suppose you have 1000 <p> tags of them only 100 are > inside #foo you'll have wasted 900 loops. > > Surely $('#foo') is the fastest lookup possible. Doing it this way > will effectively limit the scope of the $('p') search and you will > never be bothered about any <p> tags outside #foo. > > Or am I talking rubbish?