jquery text() vs native javascript innerText

Benchmark created by ArmanA on


Description

jquery text() vs innerText

Preparation HTML

<div id="myDiv">Hi</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

var yourNode = document.getElementById('myDiv');
    var yourJnode = $('#myDiv');
    var i;

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery text()
for (i = 0; i < 100; i += 1) {
  yourJnode.text('test 1');
}
ready
Native JavaScript innerText
for (i = 0; i < 100; i += 1) {
  yourNode.innerText = 'test 2';
}
ready

Revisions

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

  • Revision 1: published by ArmanA on