jQuery.height() vs. jQuery.offset() (v2)

Revision 2 of this benchmark created on


Description

In some cases, my algorithm could use with jQuery.height() or jQuery.offset().top to perform its function, so I would like to use whichever is faster.

Preparation HTML

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

<script src="https://raw.github.com/dreamerslab/jquery.actual/master/jquery.actual.min.js"></script>

<div id="item" style="background-color: #ccc; width: 100px; height: 100px; top: 100px; left: 100px;"><p>Text here...</p></div>

Setup

var $item = $("#item");

Teardown


    delete $item; // Unneeded, but sometimes it just feels good :)
  

Test runner

Ready to run.

Testing in
TestOps/sec
.offset().top
$item.offset().top;
ready
.height()
$item.height();
ready
.actual("offset").top
$item.actual("offset").top;
ready
.actual("height")
$item.actual("height");
ready

Revisions

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