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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser:
Chrome 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
setAttribute
311.7 Ops/sec
style
336.2 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]; }