Element.matches() VS Element.classList.contains()

Benchmark created on


Preparation HTML

<div id="test" class="testing"></div>

Setup

let $element = document.getElementById('test');

Teardown

delete $element;

Test runner

Ready to run.

Testing in
TestOps/sec
Element.matches()
if ($element.matches('.testing')) {
	console.log(true);
}
ready
Element.classList.contains()
if ($element.classList.contains('.testing')) {
	console.log(true);
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.