Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
ClassList has add or direct add
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0
Browser:
Firefox 139
Operating system:
Windows
Device Platform:
Desktop
Date tested:
11 months ago
Test name
Executions per second
check has and add class
17712532.0 Ops/sec
Direct add class
2421664.2 Ops/sec
HTML Preparation code:
<div class="el"></div>
Script Preparation code:
var el = document.querySelector('.el')
Tests:
check has and add class
!el.classList.contains('el') && el.classList.add('el') !el.classList.contains('el2') && el.classList.add('el2')
Direct add class
el.classList.add('el') el.classList.add('el2')