Current

Benchmark created on


Preparation HTML

<div class="module--PageHeaderV2"></div>
<div class="module--NavigationV2"></div>
<div class="module--PageHeaderV2"></div>
<div class="module--NavigationV2"></div>
<div class="module--PageHeaderV2"></div>
<div class="module--NavigationV2"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
Current
if( document.querySelectorAll(".module--PageHeaderV2").length ) {
	document.querySelectorAll(".module--PageHeaderV2").forEach(el => {
        // do stuff
    });
}
if( document.querySelectorAll(".module--NavigationV2").length ) {
	document.querySelectorAll(".module--NavigationV2").forEach(el => {
        // do stuff
    });
}
ready
New
document.querySelectorAll(".module").forEach(el => {
    if( el.classList.contains("module--PageHeaderV2") ) {

    } else if( el.classList.contains("module--NavigationV2") ) {

    } 
});
ready
New V2
document.querySelectorAll(".module").forEach(el => {
    let classes = el.classList;
    let moduleMatch = el.className.match(/(module\-\-)(?:\S+)/g);
    let className = moduleMatch[0].split("--")[1];
    if( className === "PageHeaderV2" ) {

    } else if( className === "NavigationV2" ) {

    } 
});
ready

Revisions

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