jquery method vs function

Benchmark created by liyao on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<span id="text">
  a text sample.
</span>
<script>
  var elem = jQuery("#text");
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
elem.text()
elem.text()
ready
$.text(elem);
$.text(elem);
ready
$("#text").text()
$("#text").text()
ready
$.text($("#text"))
$.text($("#text"))
ready
elem.data("key","value")
elem.data("key","value")
ready
$.data(elem,"key","value")
$.data(elem, "key", "value")
ready

Revisions

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

  • Revision 1: published by liyao on