ID vs class vs data attribute

Benchmark created by whomba on


Preparation HTML

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

<div id="id">
<div class="id">
<div data-id>

Test runner

Ready to run.

Testing in
TestOps/sec
ID
var $x = $("#id");
ready
class
var $x = $(".id");
ready
data
var $x = $("div [data-id='']");
ready

Revisions

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