jQuery Attribute selector performance (v5)

Revision 5 of this benchmark created on


Description

Test to see if jQuery filters by selector before doing attribute matching.

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<b class="t" name="test0"></b>
<b class="t" name="test0"></b>
<b class="t" name="test0"></b>
<b class="t" name="test1"></b>
<b class="t" name="test1"></b>
<b class="t" name="test1"></b>

Setup

var html = '<b  class="t" name="test0"></b><b class="t"  name="test1"></b><b class="t"  name="test2"></b><b class="t"  name="test3"></b><b class="t"  name="test4"></b><b class="t" name="test5"></b>';
    
    var regex = /(name=['"]+([^'"]+)(?=['"]+))/g;

Test runner

Ready to run.

Testing in
TestOps/sec
Attribute matching only
$('b[name]');
ready
class
$('.t');
ready
Chained
$('b.t');
ready
Match
html.match(regex);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.