Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
className vs. setAttribute vs. classList
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser:
Chrome 137
Operating system:
Linux
Device Platform:
Desktop
Date tested:
4 months ago
Test name
Executions per second
className
8700188.0 Ops/sec
setAttribute
5595469.0 Ops/sec
classList
3314685.8 Ops/sec
HTML Preparation code:
<div id="foo"></div>
Script Preparation code:
var element = document.getElementById("foo");
Tests:
className
element.className = "bar";
setAttribute
element.setAttribute("class", "bar");
classList
element.classList.add("bar");