Re: QSA, the problem with ":scope", and naming

Yehuda Katz
(ph) 718.877.1325


On Wed, Oct 19, 2011 at 1:22 AM, Alex Russell <slightlyoff@google.com>wrote:

> On Wed, Oct 19, 2011 at 2:26 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> > On 10/18/11 8:08 PM, Alex Russell wrote:
> >>>
> >>> The other "excuse" is that adding special cases (which is what you're
> >>> asking
> >>> for) slows down all the non-special-case codepaths.  That may be fine
> for
> >>> _your_ usage of querySelectorAll, where you use it with a particular
> >>> limited
> >>> set of selectors, but it's not obvious that this is always a win.
> >>
> >> Most browsers try to optimize what is common.
> >
> > Yes, but what is common for Yehuda may well not be globally common.
>
> Yehuda is representing jQuery. I'll take his opinion as the global
> view unless he choses to say he's representing a personal opinion.
>

Right. I'm representing the position of jQuery. Sizzle (John's selector
engine, used by jQuery) chose to optimize certain common selectors after an
analysis of selectors used by jQuery found that a large percentage of all
selectors used were a few simple forms that were amenable to
getElement(s)By* optimizations. I provided a link to the code that
implements this earlier in this thread.


> > There's also the question of premature optimization.  Again, I'd love to
> see
> > a non-synthetic situation where any of this matters.  That would be a
> much
> > more useful point to reason from than some sort of hypothetical
> faith-based
> > optimization.
>
> The jQuery team did look to see what selector are "hottest" against
> their engine at some point and explicitly optimize short selectors as
> a result. The simple forms seem to be the most common.
>

Yep.


>
> Regards
>
>

Received on Wednesday, 19 October 2011 09:42:30 UTC