Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 OPR/83.0.4254.70
Opera 83
Windows
Desktop
2 years ago
Test name Executions per second
Jquery 11174.0 Ops/sec
Vanilla JS 16569.4 Ops/sec
HTML Preparation code:
x
 
1
<script src='https://code.jquery.com/jquery-3.6.0.min.js'></script>
2
3
<div id='test' data-count="0"></div>
Tests:
  • Jquery

     
    for(let i = 0; i < 10; i++) {
     $('#test').text("actual count value is : "+$('#test').data('count'));
     $('#test').data('count', +$('#test').data('count')+1); 
    }
  • Vanilla JS

     
    for(let i = 0; i < 10; i++) {
      document.querySelector('#test').innerText = "actual count value is : "+document.querySelector('#test').dataset.count;
      document.querySelector('#test').dataset.count = +document.querySelector('#test').dataset.count+1;
    }