jQuery class vs attribute selectors (v7)

Revision 7 of this benchmark created on


Description

Test performance of jQuery of using the class selector ".classname" vs the attribute selector "[class='classname']"

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<a data-multiplevalues="valuea valueb valuec">Test</a>

Test runner

Ready to run.

Testing in
TestOps/sec
attribute starts with selector
var content = jQuery("a[data-multiplevalues^='valuea']");
ready
attribute contains selector
var content = jQuery("a[data-multiplevalues*='valuea']");
ready
attribute contains word selector
var content = jQuery("a[data-multiplevalues~='valuea']");
ready
attribute ends selector
var content = jQuery("a[data-multiplevalues$='valuec']");
ready
attribute not equal selector
var content = jQuery("a[data-multiplevalues!='valuea']");
ready

Revisions

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