Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Setting CSS: Direct CSS property vs setAttribute("style",...)
Which one is more efficiente setAttribute("style","color:red") or a.style.color = 'red'
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/129.0.0.0 Safari/537.36
Browser:
Chrome 129
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
setAttribute
6.6M/s
CSS properties
4.5M/s
View exact numbers
Test name
Executions per second
✓
setAttribute
6,621,586 Ops/sec
CSS properties
4,452,169 Ops/sec
HTML Preparation code:
<span id="testElement">Test text</span>
Script Preparation code:
var a = document.getElementById("testElement");
Tests:
setAttribute
a.setAttribute("style","color:red");
CSS properties
a.style.color = 'red';