Reputation: 27689
Which one is fastest?
$('#main_body').find('[data-table="'+table+'"]:first > tbody > [data-id='+id+']:first');
$('#main_body').find('[data-table="'+table+'"]:first').children('tbody').children('[data-id='+id+':first]');
Upvotes: 2
Views: 106
Reputation: 9000
For a direct answer, I suggest using tools like jsperf and do some test.
Like: https://jsperf.com/what-is-fastest-single-selector-or-multiple.
Which give us:
single selector : 19,992 ±2.49% (ops/sec) fastest
multiple selectors: 16,035 ±3.91% (ops/sec) 21% slower
For a full answer and explanation, I presume the first will be always quicker because is a one function call agains three.
Upvotes: 1