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
<div id="foo">Hello World</div>
Tests:
  • Vanilla JS .innerText

     
    var el = document.getElementById("foo");
    var text = el.innerText;
  • Vanilla JS .innerHTML

     
    var el = document.getElementById("foo");
    var text = el.innerHTML;
  • Vanilla JS .textContent

     
    var el = document.getElementById("foo");
    var text = el.textContent;
  • Vanilla JS (querySelector) .innerText

     
    var el = document.querySelector("#foo");
    var text = el.innerText;
  • Vanilla JS (querySelector) .innerHTML

     
    var el = document.querySelector("#foo");
    var text = el.innerHTML;
  • Vanilla JS (querySelector) .textContent

     
    var el = document.querySelector("#foo");
    var text = el.textContent;
  • Vanilla JS (querySelectorAll) .innerText

     
    var el = document.querySelectorAll("#foo");
    var text = el.innerText;
  • Vanilla JS (querySelectorAll) .innerHTML

     
    var el = document.querySelectorAll("#foo");
    var text = el.innerHTML;
  • Vanilla JS (querySelectorAll) .textContent

     
    var el = document.querySelectorAll("#foo");
    var text = el.textContent;
  • Cash .text

     
    var text = $("#foo").text();
  • Cash .html

     
    var text = $("#foo").html();
  • jQuery .text()

     
    var text = jQuery("#foo").text();
  • jQuery .html()

     
    var text = jQuery("#foo").html();
  • jQuery .find() .text()

     
    var text = jQuery(document).find("#foo").text();
  • jQuery .find() .html()

     
    var text = jQuery(document).find("#foo").html();
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Vanilla JS .innerText
    Vanilla JS .innerHTML
    Vanilla JS .textContent
    Vanilla JS (querySelector) .innerText
    Vanilla JS (querySelector) .innerHTML
    Vanilla JS (querySelector) .textContent
    Vanilla JS (querySelectorAll) .innerText
    Vanilla JS (querySelectorAll) .innerHTML
    Vanilla JS (querySelectorAll) .textContent
    Cash .text
    Cash .html
    jQuery .text()
    jQuery .html()
    jQuery .find() .text()
    jQuery .find() .html()

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0
Firefox 106 on Windows
View result in a separate tab
Test name Executions per second
Vanilla JS .innerText 2403249.0 Ops/sec
Vanilla JS .innerHTML 6052508.5 Ops/sec
Vanilla JS .textContent 6097351.0 Ops/sec
Vanilla JS (querySelector) .innerText 1848596.9 Ops/sec
Vanilla JS (querySelector) .innerHTML 3653835.0 Ops/sec
Vanilla JS (querySelector) .textContent 3671760.5 Ops/sec
Vanilla JS (querySelectorAll) .innerText 1146966.2 Ops/sec
Vanilla JS (querySelectorAll) .innerHTML 1295210.1 Ops/sec
Vanilla JS (querySelectorAll) .textContent 1370492.6 Ops/sec
Cash .text 5085199.5 Ops/sec
Cash .html 3310898.8 Ops/sec
jQuery .text() 2858574.5 Ops/sec
jQuery .html() 2742344.8 Ops/sec
jQuery .find() .text() 1189870.5 Ops/sec
jQuery .find() .html() 1190930.8 Ops/sec