jqmData V.S. getAttribute

JavaScript performance comparison

Revision 2 of this test case created by frequent

Info

jqmData is replaced to getAttribute in the jquery.mobile.buttonMarkup.js

Preparation code

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>

<div data-role="page" id="main-page">
  <div data-role="header">Test</div>
  <div data-role="content" id="content">
    <div id="abc" data-foo="bar">hello</div>
  </div>
</div>

Preparation code output

Test
hello

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
jqmData()
$('#abc').jqmData("foo");
pending…
attr
$('#abc').attr("data-foo");
pending…
getAttribute
document.getElementById("abc").getAttribute("data-foo");
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment