Attr vs hasAttr

Benchmark created by Orkel on


Preparation HTML

<script src="https://code.jquery.com/jquery-1.7b1.js"></script>
<script>
var $current = jQuery.noConflict(); 
</script>

<script src="https://docs.google.com/uc?id=0B6yiDAQGhvdFZjVjM2U4NmQtMzNhYi00NzljLTllZDUtNmRlZmYyOGRjZWYx&export=download"></script>
<script>
var $test = jQuery.noConflict(); 
</script>
<div class="parent">
<div bla="bla"></div>
</div>

Setup

var currentDiv = $current( ".parent > div" ),
    testDiv = $test( ".parent > div" );

Test runner

Ready to run.

Testing in
TestOps/sec
attr
!!currentDiv.attr("bla");
ready
hasAttr
testDiv.hasAttr("bla");
ready

Revisions

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

  • Revision 1: published by Orkel on