Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0
Firefox 82
Windows
Desktop
4 years ago
Test name Executions per second
jQuery 3.3.1 3785695.2 Ops/sec
jQuery 2.1.4 3237103.2 Ops/sec
Vanilla JS querySelector 2517186.8 Ops/sec
Vanilla JS getElementById 3237712.2 Ops/sec
HTML Preparation code:
AخA
 
1
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js'></script>
2
<script type="text/javascript">
3
  var jq331 = $.noConflict(true);
4
</script>
5
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js'></script>
6
<script type="text/javascript">
7
  var jq214 = $.noConflict(true);
8
</script>
9
<div id="testElement"></div>
Tests:
  • jQuery 3.3.1

     
    var el = jq331("#testElement")[0];
    var className = el.className;
  • jQuery 2.1.4

     
    var el = jq214("#testElement")[0];
    var className = el.className;
  • Vanilla JS querySelector

     
    var el = document.querySelector('#testElement');
    var className = el.className;
  • Vanilla JS getElementById

     
    var el = document.getElementById('testElement');
    var className = el.className;