[jQuery] .prop() versus .attr()

Benchmark created by Brian on


Description

Measures the performance of getting and setting DOM properties.

Preparation HTML

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

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

Test runner

Ready to run.

Testing in
TestOps/sec
.prop() GET
$("#test").prop('className');
ready
.prop() SET
$("#test").prop('className', 'changed');
ready
.attr() GET
$("#test").attr('class');
ready
.attr() SET
$("#test").attr('class', 'changed');
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