JQuery $(this).attr("name") vs this.name - by zebra

Benchmark created on


Description

Compare $(this).attr("name") with this.name

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div name="one">
</div>
<div name="two">
</div>
<div name="three">
</div>
<div name="four">
</div>
<div name="five">
</div>
<div name="six">
</div>

Test runner

Ready to run.

Testing in
TestOps/sec
$(this).attr("name")
$("div").each(function() {
  var msg = $(this).attr("name");
});
ready
this.name
$("div").each(function() {
  var msg = this.name;
});
ready

Revisions

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