id vs name selector speed

Benchmark created on


Preparation HTML

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

<div class="abc">
</div>
<div>
<div id="something" class="something">
  <p>Some test text</p>
  <p>Some test text</p>
  <p>Some test text</p>
</div>
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
class selector
var text = $('.something').text();
ready
id selector
var text = $('#something').text();
ready
id selector raw
var text = document.getElementById('something').innerHTML;
ready

Revisions

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