Run details:
Mozilla/5.0 (Linux; Android 10; POCOPHONE F1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.114 Mobile Safari/537.36
Chrome Mobile 86
Android
Mobile
4 years ago
Test name Executions per second
Vanilla JS .innerText 442182.3 Ops/sec
Vanilla JS .innerHTML 136575.1 Ops/sec
Vanilla JS .textContent 1511749.4 Ops/sec
Vanilla JS (QuerySelector) .innerText 332211.9 Ops/sec
Vanilla JS (QuerySelector) .innerHTML 123332.0 Ops/sec
Vanilla JS (QuerySelector) .textContent 839217.2 Ops/sec
Vanilla JS (QuerySelectorAll) .innerText 501507.3 Ops/sec
Vanilla JS (QuerySelectorAll) .innerHTML 482007.0 Ops/sec
Vanilla JS (QuerySelectorAll) .textContent 488137.5 Ops/sec
Cash .text 532857.9 Ops/sec
Cash .html 90558.4 Ops/sec
jQuery .text() 189087.3 Ops/sec
jQuery .html() 74662.7 Ops/sec
jQuery .find() .text() 137855.3 Ops/sec
jQuery .find() .html() 62234.6 Ops/sec
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");
    el.innerText = "New Hello World";
  • Vanilla JS .innerHTML

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

     
    var el = document.getElementById("foo");
    el.textContent = "New Hello World";
  • Vanilla JS (QuerySelector) .innerText

     
    var el = document.querySelector("#foo");
    el.innerText = "New Hello World";
  • Vanilla JS (QuerySelector) .innerHTML

     
    var el = document.querySelector("#foo");
    el.innerHTML = "New Hello World";
  • Vanilla JS (QuerySelector) .textContent

     
    var el = document.querySelector("#foo");
    el.textContent = "New Hello World";
  • Vanilla JS (QuerySelectorAll) .innerText

     
    var el = document.querySelectorAll("#foo");
    el.innerText = "New Hello World";
  • Vanilla JS (QuerySelectorAll) .innerHTML

     
    var el = document.querySelectorAll("#foo");
    el.innerHTML = "New Hello World";
  • Vanilla JS (QuerySelectorAll) .textContent

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

     
    $("#foo").text("New Hello World");
  • Cash .html

     
    $("#foo").html("New Hello World");
  • jQuery .text()

     
    jQuery("#foo").text("New Hello World");
  • jQuery .html()

     
    jQuery("#foo").html("New Hello World");
  • jQuery .find() .text()

     
    jQuery(document).find("#foo").text("New Hello World");
  • jQuery .find() .html()

     
    jQuery(document).find("#foo").html("New Hello World");