id vs class vs tag selectors (v13)

Revision 13 of this benchmark created on


Preparation HTML

<p id="foo" class="foo"></p>

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

Test runner

Ready to run.

Testing in
TestOps/sec
id
var element = document.getElementById('foo');
ready
class
var element = $('p.foo');
ready
tag
var element = $('p#foo');
ready
$(id)
var element = $('#foo');
ready
$(class)
var element = $('.foo');
ready
$(tag)
var element = $('p');
ready

Revisions

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