span. TestSpan"); var elems2 = $("data-group..." />

Will there be a performance increase if using custom attribute selectors instead of long mixed class/tag selectors with jQuery?

The longer selectors should be faster. Here's an example. Given the following HTML: div class="testDiv"> span.

TestSpan"); var elems2 = $("data-group='testSpan'") Here's the results from a quick test : However, it's worth noting that in the real world the difference is going to be minimal and you should use whichever suits you best You could make your data selector slightly better (performance-wise) by making it more specific: var elems = $("spandata-group='testSpan'") But another quick test reveals (for me, in Chrome 15 at least) that the longer selectors still win I think in older browsers with no support for querySelectorAll the difference will be even more pronounced in favour of the longer selectors, which can use the native getElementsByTagName.

The longer selectors should be faster. Here's an example. Given the following HTML: And the following jQuery: var elems1 = $("div.

TestDiv > span. TestSpan"); var elems2 = $("data-group='testSpan'"); Here's the results from a quick test: However, it's worth noting that in the real world the difference is going to be minimal and you should use whichever suits you best. You could make your data-* selector slightly better (performance-wise) by making it more specific: var elems = $("spandata-group='testSpan'"); But another quick test reveals (for me, in Chrome 15 at least) that the longer selectors still win.

I think in older browsers with no support for querySelectorAll, the difference will be even more pronounced in favour of the longer selectors, which can use the native getElementsByTagName.

Well, this proves that I was wrong. Great explanation, thanks. – Martin Nov 5 at 20:19.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions