Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
className vs classList normalization
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/133.0.0.0 Safari/537.36
Browser:
Chrome 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
className
7970.1 Ops/sec
classList with array from
1334.2 Ops/sec
classList with spread operator
1609.6 Ops/sec
HTML Preparation code:
<div id="foo" class="bar test space OK"></div>
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); }
Tests:
className
let element = document.getElementById("foo"); let i = 1000; while (i--) { let selector = "." + element.className.trim().replace(/\s+/g, '.'); }
classList with array from
let element = document.getElementById("foo"); let i = 1000; while (i--) { let selector = "." + Array.from(element.classList).join('.'); }
classList with spread operator
let element = document.getElementById("foo"); let i = 1000; while (i--) { let selector = "." + [...element.classList].join('.'); }