find() & remove() vs empty() (v5)

Revision 5 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
html("")
$('#mySelect').html("").append('<option selected="selected" value="whatever">text</option>');
ready

Revisions

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