data-attr

JavaScript performance comparison

Revision 20 of this test case created by

Preparation code

<div id="div"></div>
<script>
var div = document.getElementById('div');
</script>
    

Preparation code output

<div id="div"></div>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
setAttribute
div.setAttribute('data-yo', 'yo');
div.setAttribute('data-ma', 'ma');
div.setAttribute('data-la', 'la');
var a = div.getAttribute('data-yo');
var b = div.getAttribute('data-ma');
var c = div.getAttribute('data-la');
pending…
Data
div.__data={yo: 'yo', ma: 'ma', la: 'la'};
var data = div.__data;
var a = data.yo;
var b = data.ma;
var c = data.la;
pending…
dataset
div.dataset.yo = 'yo';
div.dataset.ma = 'ma';
div.dataset.la = 'la';
var data = div.dataset;
var a = data.yo;
var b = data.ma;
var c = data.la;
pending…
object
var __data={yo: 'yo', ma: 'ma', la: 'la'};
var data = __data;
var a = data.yo;
var b = data.ma;
var c = data.la;
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.

0 Comments