Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0
Firefox 64
Windows
Desktop
6 years ago
Test name Executions per second
jQuery 3090.0 Ops/sec
pure JS 5138.2 Ops/sec
HTML Preparation code:
AخA
 
1
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
Script Preparation code:
 
var frag = document.createDocumentFragment();
for (var i=0; i<100; i++){
  var inDiv = document.createElement('span');
  inDiv.id="s_"+i;
  inDiv.innerHTML = 'bla';
  inDiv.className = 'myclass';
  frag.appendChild(inDiv);
}
document.body.appendChild(frag);
Tests:
  • jQuery

     
    $('span.myclass').each(function () {
      $(this).html('x');
    });
  • pure JS

     
    $('span.myclass').each(function () {
      this.innerHTML = 'y';
    });