Test name | Executions per second |
---|---|
dataset | 5517.9 Ops/sec |
setAttribute | 9831.0 Ops/sec |
<div id='set' data-open="0"></div>
const elem = document.getElementById("set");
var i = 1000;
while (i--) {
elem.dataset.open = "1";
}
const elem = document.getElementById("set");
var i = 1000;
while (i--) {
elem.setAttribute('data-open', '1')
}