Test name | Executions per second |
---|---|
Pure JS .innerText | 1698721.8 Ops/sec |
Pure JS .innerHTML | 188672.1 Ops/sec |
Pure JS .textContent | 3031215.2 Ops/sec |
jQuery .text() | 399184.2 Ops/sec |
jQuery .html() | 103455.3 Ops/sec |
jQuery .find().text() | 226054.1 Ops/sec |
jQuery .find().html() | 94136.4 Ops/sec |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"><script>
<script>jQuery.noConflict();</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/7.0.3/cash.min.js"></script>
<div id="foo">Hello World</div>
var el = document.getElementById("foo");
el.innerText = "New Hello World";
var el = document.getElementById("foo");
el.innerHTML = "New Hello World";
var el = document.getElementById("foo");
el.textContent = "New Hello World";
var el = document.querySelector("#foo");
el.innerText = "New Hello World";
var el = document.querySelector("#foo");
el.innerHTML = "New Hello World";
var el = document.querySelector("#foo");
el.textContent = "New Hello World";
var el = document.querySelectorAll("#foo");
el.innerText = "New Hello World";
var el = document.querySelectorAll("#foo");
el.innerHTML = "New Hello World";
var el = document.querySelectorAll("#foo");
el.textContent = "New Hello World"
$("#foo").text("New Hello World");
$("#foo").html("New Hello World");
jQuery("#foo").text("New Hello World");
jQuery("#foo").html("New Hello World");
jQuery(document).find("#foo").text("New Hello World");
jQuery(document).find("#foo").html("New Hello World");