id vs class vs tag vs pseudo vs. attribute selectors

JavaScript performance comparison

Test case created by Gromer

Preparation code

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

<input type="hidden" id="my-id" class="my-class" />
    

Preparation code output

<input type="hidden" id="my-id" class="my-class" />

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
id
var temp = $('#my-id');
pending…
class
var temp = $('.my-class');
pending…
tag
var temp = $('input');
pending…
pseudo
var temp = $(':hidden');
pending…
attribute
var temp = $('[type="hidden"]');
pending…

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

Compare results of other browsers

0 Comments