Jquery .css() vs JS.style (v17)

Revision 17 of this benchmark created on


Description

Move an element

Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div id="test" style="position:absolute;top:100px;left:200px;"></div>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery
var myelem = jQuery('#test');
$(myelem).css({
 left: "20px",
 top: "20px"
});
ready
JS
var myelem = document.getElementById("test");
myelem.style.top = "20px";
myelem.style.left = "20px";
ready
jQuery 2
var $myelem = jQuery('#test');
$myelem.css({
 left: "20px",
 top: "20px"
});
ready
var myelem = document.getElementById("test");
$(myelem).css({
 left: "20px",
 top: "20px"
});
ready

Revisions

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