Description
In http://learn.jquery.com/performance/optimize-selectors/ you say:
"Be specific on the right-hand side of your selector, and less specific on the left."
I've opened a thread on SO: http://stackoverflow.com/questions/34923710/selectors-be-specific-on-right-hand-side
Two people so far have done benchmarks and the version where the right-hand side is more specific is always performing worse. Basically, in modern browsers supporting queryselectorall, as far as I'm aware, the Sizzle engine is not used for processing the selector. So basically, as far as I'm aware, in modern browsers, it's about how many operation there are to evaluate the result.
In $( ".data .gonzalez" )
, there are 2 operations (1 for looking up CSS class results, 1 for tag results), while in $( ".data td.gonzalez" )
there are 3 operations (2 for looking up CSS class results, 1 for tag results) which is why I suspect the second version is slower in most browsers.
Correct me if I'm wrong.