Test name | Executions per second |
---|---|
setProperty | 2879.5 Ops/sec |
cssText | 1833.6 Ops/sec |
setAttribute | 4333.3 Ops/sec |
style property | 3247.6 Ops/sec |
<div id="test"></div>
globalThis.test = document.getElementById('test');
let i = 1000;
while (i -= 1) {
test.style.setProperty('color', 'red');
}
let i = 1000;
while (i -= 1) {
test.style.cssText = 'color: red';
}
let i = 1000;
while (i -= 1) {
test.setAttribute('style', 'color: red');
}
let i = 1000;
while (i -= 1) {
test.style.color = 'red';
}