HTML Preparation code:
AخA
 
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"><script>
2
<script>jQuery.noConflict();</script>
3
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/7.0.3/cash.min.js"></script>
4
  <script src="https://cdn.jsdelivr.net/npm/umbrellajs"></script>
5
<div id="foo" class="foo2"></div>
Tests:
  • getElementById

     
    var el = document.getElementById("foo");
    var className = el.className;
  • Umbrella(tag.id)

     
    var el = u("div.foo2");
    var className = el.className;
  • Umbrella(tag#id)

     
    var el = u("div#foo");
    var className = el.className;
  • Umbrella(.id)

     
    var el = u(".foo2");
    var className = el.className;
  • Umbrella(#id)

     
    var el = u("#foo");
    var className = el.className;
  • jQuery + getElementsByClassName

     
    var el = jQuery(document.getElementsByClassName("foo2"));
    var className = el.className;
  • jQuery + getElementById

     
    var el = jQuery(document.getElementById("foo"));
    var className = el.className;
  • jQuery (tag.id)

     
    var el = jQuery("div.foo2");
    var className = el.className;
  • jQuery (tag#id)

     
    var el = jQuery("div#foo");
    var className = el.className;
  • jQuery (.id)

     
    var el = jQuery(".foo2");
    var className = el.className;
  • jQuery (#id)

     
    var el = jQuery("#foo");
    var className = el.className;
  • Umbrella + getElementById

     
    var el = u(document.getElementById("foo"));
    var className = el.className;
  • Cash + getElementsByClassName

     
    var el = $(document.getElementsByClassName("foo2"));
    var className = el.className;
  • Cash (tag.id)

     
    var el = $("div.foo2");
    var className = el.className;
  • Cash (tag#id)

     
    var el = $("div#foo");
    var className = el.className;
  • Cash (.id)

     
    var el = $(".foo2");
    var className = el.className;
  • Cash (#id)

     
    var el = $("#foo");
    var className = el.className;
  • querySelectorAll (.id)

     
    var el = document.querySelectorAll('.foo2');
    var className = el.className;
  • querySelectorAll (#id)

     
    var el = document.querySelectorAll('#foo');
    var className = el.className;
  • querySelector (.id)

     
    var el = document.querySelector('.foo2');
    var className = el.className;
  • querySelector (#id)

     
    var el = document.querySelector('#foo');
    var className = el.className;
  • getElementsByTagName

     
    var el = document.getElementsByTagName("div")[0];
    var className = el.className;
  • getElementsByClassName

     
    var el = document.getElementsByClassName("foo2");
    var className = el.className;
  • Cash + getElementById

     
    var el = $(document.getElementById("foo"));
    var className = el.className;
  • Umbrella + getElementsByClassName

     
    var el = u(document.getElementsByClassName("foo2"));
    var className = el.className;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    getElementById
    Umbrella(tag.id)
    Umbrella(tag#id)
    Umbrella(.id)
    Umbrella(#id)
    jQuery + getElementsByClassName
    jQuery + getElementById
    jQuery (tag.id)
    jQuery (tag#id)
    jQuery (.id)
    jQuery (#id)
    Umbrella + getElementById
    Cash + getElementsByClassName
    Cash (tag.id)
    Cash (tag#id)
    Cash (.id)
    Cash (#id)
    querySelectorAll (.id)
    querySelectorAll (#id)
    querySelector (.id)
    querySelector (#id)
    getElementsByTagName
    getElementsByClassName
    Cash + getElementById
    Umbrella + getElementsByClassName

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 4 months ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0
Firefox 132 on Ubuntu
View result in a separate tab
Test name Executions per second
getElementById 5921505.0 Ops/sec
Umbrella(tag.id) 659797.1 Ops/sec
Umbrella(tag#id) 617042.3 Ops/sec
Umbrella(.id) 656626.9 Ops/sec
Umbrella(#id) 644504.4 Ops/sec
jQuery + getElementsByClassName 1286030.8 Ops/sec
jQuery + getElementById 4125965.8 Ops/sec
jQuery (tag.id) 962611.7 Ops/sec
jQuery (tag#id) 945863.2 Ops/sec
jQuery (.id) 1985559.5 Ops/sec
jQuery (#id) 7407952.5 Ops/sec
Umbrella + getElementById 1186384.8 Ops/sec
Cash + getElementsByClassName 2517597.5 Ops/sec
Cash (tag.id) 1293283.9 Ops/sec
Cash (tag#id) 1204281.9 Ops/sec
Cash (.id) 2809035.5 Ops/sec
Cash (#id) 7760837.0 Ops/sec
querySelectorAll (.id) 1545229.5 Ops/sec
querySelectorAll (#id) 1408590.6 Ops/sec
querySelector (.id) 3549211.2 Ops/sec
querySelector (#id) 3579967.0 Ops/sec
getElementsByTagName 4813066.5 Ops/sec
getElementsByClassName 3164335.8 Ops/sec
Cash + getElementById 3873927.0 Ops/sec
Umbrella + getElementsByClassName 939420.4 Ops/sec