Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Check if an element contains a class name using a regular expression
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/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
loop
102862.0 Ops/sec
className
180466.5 Ops/sec
HTML Preparation code:
<div class='one two three four five six seven eight nine testClass hello_world' id='demoBlock'></div>
Script Preparation code:
var el = document.getElementById('demoBlock');
Tests:
loop
for (var i=0, l=el.classList.length; i<l; ++i) { if(/hello_[^\s]+/.test(el.classList[i])) { console.log('found') break; } }
className
if (/hello_[^\s]+/.test(el.className)) { console.log('found') }