id vs class vs tag selectors (v214)

Revision 214 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 = $(document.getElementsByClassName('foo'));
ready
tag
var element = $(document.getElementsByTagName('p'));
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.