ScrollHeight: jQuery vs Javascript (v4)

Revision 4 of this benchmark created on


Preparation HTML

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

<script>
  function getScrollPosition() {
           var scroll = (document.documentElement && document.documentElement.scrollLeft) || window.pageXOffset || self.pageXOffset || document.body.scrollLeft; 
  
         return scroll;
      }

var $window = $(window);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
var scrollTop = $window.scrollTop();
var scrollBottom = $window.height() + scrollTop;
ready
JavaScript
var scrollTop = getScrollPosition();
var scrollBottom = scrollTop + document.documentElement.clientHeight;
ready
jQuery scrollTop
var scrollTop = $window.scrollTop();
ready
JavaScript scrollTop
var scrollTop = getScrollPosition();
ready
jQuery Window Height
var windowHeight = $window.height();
ready
JavaScript Window Height
var windowHeight = document.documentElement.clientHeight;
ready

Revisions

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