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 (X11; Linux x86_64; rv:139.0) Gecko/20100101 Firefox/139.0
Browser:
Firefox 139
Operating system:
Linux
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
setAttribute
4725595.0 Ops/sec
CSS properties
783012.6 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';