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
Test name
Executions per second
setAttribute
12.0 Ops/sec
style
17.3 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]; }