Jquery attr vs data (v2)

Revision 2 of this benchmark created by kent1 on


Description

See http://stackoverflow.com/q/9783598/1219121

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>


        <div id="rp1">Testdiv 1</div>
        <div id="rp2" data-test="1">Testdiv 2</div>

Setup

var rp1 = $("#rp1");
     var rp2 = $("#rp2");

Test runner

Ready to run.

Testing in
TestOps/sec
attr1
rp1.attr("data-test","a"+5);
ready
data1
rp1.data("data-test","a"+5);
ready
attr2
rp2.attr("data-test","a"+5);
ready
data2
rp2.data("data-test","a"+5);
ready
prop1
rp1.prop("data-test","a"+5);
ready

Revisions

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

  • Revision 1: published by Neysor on
  • Revision 2: published by kent1 on