find() & remove() vs empty() (v7)

Revision 7 of this benchmark created on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<select id="mySelect">
  <option value="volvo">
    Volvo
  </option>
  <option value="saab">
    Saab
  </option>
  <option value="mercedes">
    Mercedes
  </option>
  <option value="audi">
    Audi
  </option>
</select>

Test runner

Ready to run.

Testing in
TestOps/sec
find() & remove()
$('#mySelect').find('option').remove().end().append('<option value="whatever">text</option>').val('whatever');
ready
empty()
$('#mySelect').empty().append('<option selected="selected" value="whatever">text</option>');
ready
options.length = 0
$select = $('#mySelect');
$select[0].options.length = 0;
$select.append('<option selected="selected" value="whatever">text</option>');
ready
$('#mySelect option').remove()
$('#mySelect option').remove();
$('#mySelect').append('<option value="whatever">text</option>').val('whatever');
ready

Revisions

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