Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
setAttribute vs style.cssText test
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0
Browser:
Firefox 137
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
style
17/s
setAttribute
12/s
View exact numbers
Test name
Executions per second
✓
style
17 Ops/sec
setAttribute
12 Ops/sec
HTML Preparation code:
<div id="foo"></div>
Script Preparation code:
var element = document.getElementById("foo"); const array = new Array(10000); for (var i = 0; i < array.length; i++) { array[i] = `width: ${i}px; height: ${i}px;` }
Tests:
setAttribute
for (var i = 0; i < array.length; i++) { element.setAttribute("style", array[i]); }
style
for (var i = 0; i < array.length; i++) { element.style.cssText = array[i]; }