Test name | Executions per second |
---|---|
getAttribute | 4757.0 Ops/sec |
dataset | 1792.7 Ops/sec |
<div id="foo" data-foo="foo_id"></div>
var element = document.getElementById("foo");
var i = 10000;
while (i--) {
var foo = element.getAttribute("data-foo");
}
var element = document.getElementById("foo");
var i = 10000;
while (i--) {
var foo = element.dataset.foo;
}