jQuery -- .html() vs. .text() vs. innerHTML vs. innerText/textContent (v12)

Revision 12 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<div id="test-element"></div>

Setup

var plainText = "testing";
  
  $('#test-element').empty();

Teardown



            $('#test-element').empty();
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery .html()
$('#test-element').html(plainText);
ready
jQuery .text()
$('#test-element').text(plainText);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.