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 |
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js'></script>
<script type="text/javascript">
var jq331 = $.noConflict(true);
</script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js'></script>
<script type="text/javascript">
var jq214 = $.noConflict(true);
</script>
<div id="testElement"></div>
var el = jq331("#testElement")[0];
var className = el.className;
var el = jq214("#testElement")[0];
var className = el.className;
var el = document.querySelector('#testElement');
var className = el.className;
var el = document.getElementById('testElement');
var className = el.className;