optimize-selectors qSA before Sizzle #694
Conversation
|
|
||
| Beginning your selector with an ID is always best. | ||
| ``` |
AurelioDeRosa
Jan 21, 2016
Member
I think this example might need a small introduction. Even 1-2 sentences should do it.
I think this example might need a small introduction. Even 1-2 sentences should do it.
| $( "#container" ).find( "div.robotarm" ); | ||
| ## Try to segregate the nonstandard parts of your selection | ||
|
|
||
| When you select elements, jQuery will call `querySelectorAll` with your selection. If `querySelectorAll` throws an error, jQuery will refer to its Sizzle engine. So, if you are using at least one of these nonstandard pseudo-classes: `:contains()`, `:has`, `:even`, `:submit`, etc. You will not take advantage of the native `querySelectorAll`. |
AurelioDeRosa
Jan 21, 2016
Member
I think this sentence
if you are using at least one of these nonstandard pseudo-classes: :contains(), :has,
can be tweaked a bit
if you are using at least one of the nonstandard pseudo-classes such as :contains(), :has,
I think this sentence
if you are using at least one of these nonstandard pseudo-classes:
:contains(),:has,
can be tweaked a bit
if you are using at least one of the nonstandard pseudo-classes such as
:contains(),:has,
| ``` | ||
| // A long selection with nonstandard pseudo-classes inside: |
AurelioDeRosa
Jan 21, 2016
Member
Maybe we can remove the colon at the end of this comment and the next for consistency. This isn't very important, though.
Maybe we can remove the colon at the end of this comment and the next for consistency. This isn't very important, though.
|
Hi @mr21. Are you still interested in this PR? |
|
... I'm really sorry, yes I'm still interested. |
|
@mr21 Make sure you rebase from here before continuing your work. I merged a PR based on another issue and removed/rearranged a bunch of stuff, so you might have conflicts. |
|
Understood :) |
|
Hi :) So, I have rebased and repush again my commit with the @AurelioDeRosa's modifications. |
|
Hi @mr21. With "yet" you mean that you'll add another commit to update the PR? |
|
Hi :) For the moment I have replaced this: ID-Based SelectorsBeginning your selector with an ID is a safe bet. // Fast:
$( "#container div.robotarm" );
// Super-fast:
$( "#container" ).find( "div.robotarm" );With the first approach, jQuery queries the DOM using by this: Save calls to
|
Hi :)
Here a first draft (who probably contain few mistakes) for the issue #666.