Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
setAttribute vs classList.add (attribute adding) V2
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/118.0.5993.2470 YaBrowser/23.11.0.2470 Yowser/2.5 Safari/537.36
Browser:
Yandex Browser 23
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
classList.add
1088763.1 Ops/sec
setAttribute
1474.8 Ops/sec
HTML Preparation code:
<div id="test" class="first">Testing</div>
Script Preparation code:
var el = document.getElementById('test');
Tests:
classList.add
el.classList.add("second");
setAttribute
el.setAttribute("class", el.className + " second");