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" name="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
name selector
var text = $('[name="something"]').text();
ready
id selector
var text = $('#something').text();
ready

Revisions

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