Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Javascript classList.contains vs element.matches vs classList.some
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:137.0) Gecko/20100101 Firefox/137.0
Browser:
Firefox 137
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
matches
6057756.5 Ops/sec
classList
3261039.0 Ops/sec
classList some
6567158.5 Ops/sec
HTML Preparation code:
<body class="foo bar baz"></body>
Tests:
matches
var i = 1000; while (i--) { if (document.body.matches(".foo.baz")) { return true; } }
classList
var i = 1000; while (i--) { if (document.body.classList.contains('foo') && document.body.classList.contains('baz')) { return true; } }
classList some
var i = 1000; while (i--) { if (['foo', 'baz'].some(className => document.body.classList.contains(className))) { return true; } }