jQuery attr() vs setAttribute (v2)

Revision 2 of this benchmark created by Kevin Reed on


Preparation HTML

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

Setup

var $test = $("#test");
    var test = document.getElementById('test');

Teardown


    test.id = 'test';
  

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
$test.attr("id", "name");
ready
native
test.setAttribute("id", "name");
ready
property
test.id = 'name';
ready

Revisions

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