Sizzle class vs tag qualfied class selector

JavaScript performance comparison

Revision 39 of this test case created by someguy

Preparation code

<div id="thisid" class="row list">
			<div class="col-lg-12">
				<div class="row">
					<div class="col-lg-12">
						<div class="inner">
              <div class="further_in">
                <a href="#">anchor</a>
                <a href="#">
                  <img src="http://placehold.it/100x50" title="some image" />
                </a>
              </div>
            </div>
						<div class="inner">
              <div class="further_in">
                <a href="#">anchor</a>
                <a href="#">
                  <img src="http://placehold.it/100x50" title="some image" />
                </a>
              </div>
            </div>
						<div class="inner">
              <div class="further_in">
                <a href="#">anchor</a>
                <a href="#">
                  <img class="theimg" src="http://placehold.it/100x50" title="some image" />
                </a>
              </div>
            </div>

        
					</div>
				</div>
			</div>

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

Preparation code output

<div id="thisid" class="row list"> <div class="col-lg-12"> <div class="row"> <div class="col-lg-12"> <div class="inner"> <div class="further_in"> <a href="#">anchor</a> <a href="#"> <img src="http://placehold.it/100x50" title="some image" /> </a> </div> </div> <div class="inner"> <div class="further_in"> <a href="#">anchor</a> <a href="#"> <img src="http://placehold.it/100x50" title="some image" /> </a> </div> </div> <div class="inner"> <div class="further_in"> <a href="#">anchor</a> <a href="#"> <img class="theimg" src="http://placehold.it/100x50" title="some image" /> </a> </div> </div> </div> </div> </div> </div>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
add to var first 2
var el = document.getElementById("thisid");
$(el).find('.inner a img');
pending…
var el = document.getElementById("thisid");
$(el).find('.further_in a img');
pending…
var el = document.getElementById("thisid");
$(el).find('div a img.theimg');
pending…
descendant tag qualified class selector
$('#thisid .further_in a img')
pending…
decendant class selector
$('#thisid div.further_in a img')
pending…
ID qualified decendant class selector
$('#thisid .inner .further_in a img')
pending…
ID decendant tag qualified class selector
$('#thisid div.inner div.further_in a img')
pending…
className only
$('#thisid').find('.further_in a img')
pending…
tag qualified className
$('#thisid').find('div.further_in a img')
pending…
id only
$('#thisid').find('div a img')
pending…
tag qualified id
$('#thisid div a img')
pending…
document.getElementById
$('#thisid').find('div.inner div.further_in a img')
pending…
add to var first.
var el = document.getElementById("thisid");
$(el).find('div a img');
pending…

Compare results of other browsers

Revisions

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

0 Comments