jQuery scrollTop() vs dom scrollTop

Benchmark created by Samuel Reed on


Preparation HTML

<div id="container" style="height: 500px; overflow: auto">
  <div id="scrollme" style="height: 2000px;"></div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Setup

$("#container").scrollTop(500);

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
var container = $("#container");
container.scrollTop();
ready
jQuery + dom method
var container = $("#container");
container[0].scrollTop;
ready
DOM Only
var container = document.getElementById("container");
container.scrollTop;
ready

Revisions

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