Javascript Matches vs Contains

Benchmark created on


Description

Matches vs Contains

Preparation HTML

<body>
	<div class="myClass"></div>
</body>

Setup

el = document.getElementsByClassName('myClass')[0]

Test runner

Ready to run.

Testing in
TestOps/sec
Matches
el.matches('.myClass')
ready
Contains
el.classList.contains('myClass')
ready

Revisions

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