jQuery attr vs data (v40)

Revision 40 of this benchmark created on


Description

This testcase compares the performance from .attr() and .data()

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="test111"><div class="line"></div><div class="line"></div><div class="node"></div><div class="ckbox checked"><input type="checkbox" value="test1.1.1" name="name" text="Test 1.1.1" style="display:none;" checked="checked"></div><div class="file"></div><a checked="true" tvalue="test1.1.1" data-tvalue="test1.1.1" tname="name">Test 1.1.1</a></div>

Test runner

Ready to run.

Testing in
TestOps/sec
data
var val = $('#test111').find('a').data('tvalue');
ready
attr
var val = $('#test111').find('a').attr('tvalue');
ready
attr with data
var val = $('#test111').find('a').attr('data-tvalue');
ready

Revisions

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