attributes vs datasets

JavaScript performance comparison

Revision 2 of this test case created by davsket

Preparation code

<div id="elem2" data-name="le second test"></div>
<script>
var elem = document.createElement('div'),
    elem2 = document.getElementById('elem2')
elem.setAttribute('data-name', 'le test')
</script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
dataset
elem.dataset.name
pending…
attribute
elem.getAttribute('data-name')
pending…
dataset in dom
elem2.dataset.name
pending…
attribute in dom
elem2.getAttribute('data-name')
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