[jQuery/Zepto] .prop() versus .attr() (v4)

Revision 4 of this benchmark created on


Description

Measures the performance of getting and setting DOM properties.

Preparation HTML

<script src="//code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="//zeptojs.com/zepto.min.js"></script>

<div id="test" class="hooray">Why, hello there!</div>

Test runner

Ready to run.

Testing in
TestOps/sec
jQuery prop GET
jQuery("#test").prop('className');
ready
jQuery attr GET
jQuery("#test").attr('class');
ready
jQuery prop SET
jQuery("#test").prop('className', 'newKlass');
ready
jQuery attr SET
jQuery("#test").attr('class', 'newKlass');
ready
Zepto prop GET
Zepto("#test").prop('className');
ready
Zepto attr GET
Zepto("#test").attr('class');
ready
Zepto prop SET
Zepto("#test").prop('className', 'newKlass');
ready
Zepto attr SET
Zepto("#test").attr('class', 'newKlass');
ready

Revisions

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

  • Revision 1: published by Brian on
  • Revision 2: published on
  • Revision 3: published by Theo Salvador on
  • Revision 4: published on
  • Revision 5: published on
  • Revision 6: published by Heavensrevenge on
  • Revision 7: published by Heavensrevenge on