JQuery element.classname vs element[id$='id']

Benchmark created by Chen Hendrawan on


Description

Comparing between selector based on classname vs some part of ID

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<p>
  <input type="textbox" id="some_long_aspnet_generated_id" class="mytextbox" />
</p>
<p>
  Other P
</p>

Test runner

Ready to run.

Testing in
TestOps/sec
element.classname
$("p input.mytextbox").val()
ready
element Id end with
$("p input[id$='generated_id']").val()
ready

Revisions

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

  • Revision 1: published by Chen Hendrawan on