getElementsByName vs jQuery name selector

JavaScript performance comparison

Test case created by Someone

Preparation code

<table id="tbl_prices" class="contbox_table" width="100%">
  <thead>
    <tr>
      <th width="20">#</th>
      <th>Συσκευασία</th>
      <th width="20">Τιμή(€)</th>
      <th width="20">Σειρά</th>
      <th width="20"><span class="icon16 icon_disabled16" title="Ανενεργό"></span></th>
      <th width="20">x</th>
    </tr>
  </thead>
  <tbody>
    <tr data-zmtable_row_id="1">
      <td class="td_ai">1</td>
      <td>Μέτρο<a class="zmval_field_placeholder"></a></td>
      <td class="td_textinput"><input type="text" name="package_price[1]" value="1.00" class="input_small"/></td>
      <td class="td_textinput"><input type="text" name="package_orderby[1]" value="1" class="input_tiny txt_package_orderby"/></td>
      <td class="td_checkbox"><input type="checkbox" name="package_disabled[1]" value="1" /></td>
      <td class="td_icon"><a class="icon_x20 zmtable_trigger_remove" title="Αφαίρεση"></a></td>
    </tr>
    <tr data-zmtable_row_id="2">
      <td class="td_ai">2</td>
      <td>Λίτρο<a class="zmval_field_placeholder"></a></td>
      <td class="td_textinput"><input type="text" name="package_price[2]" value="9.00" class="input_small"/></td>
      <td class="td_textinput"><input type="text" name="package_orderby[2]" value="2" class="input_tiny txt_package_orderby"/></td>
      <td class="td_checkbox"><input type="checkbox" name="package_disabled[2]" value="1" checked/></td>
      <td class="td_icon"><a class="icon_x20 zmtable_trigger_remove" title="Αφαίρεση"></a></td>
    </tr>
    <tr data-zmtable_row_id="3" id="row_3">
      <td class="td_ai">3</td>
      <td>Κιβώτιο<a class="zmval_field_placeholder"></a></td>
      <td class="td_textinput"><input type="text" name="package_price_3" value="80.00" class="input_small"/></td>
      <td class="td_textinput"><input type="text" name="package_orderby[3]" value="3" class="input_tiny txt_package_orderby"/></td>
      <td class="td_checkbox"><input type="checkbox" name="package_disabled[3]" value="1" /></td>
      <td class="td_icon"><a class="icon_x20 zmtable_trigger_remove" title="Αφαίρεση"></a></td>
    </tr>
    <tr class="zmtable_tpl tr_new">
      <td class="td_ai">{@ai}</td>
      <td><select name="package_unit_new[]">
          <option value="2">Δεκάδα</option>
          <option value="3">Εκατοστάδα</option>
          <option value="1">Μονάδα</option>
          <option value="8">Σακούλα</option>
          <option value="4">Χιλιάδα</option>
          <option value="126236434">ΔΕΝ ΥΠΑΡΧΕΙ</option>
          <option value="6">ΔΙΠΛΟ (ΛΙΤΡΟ)</option>
        </select></td>
      <td class="td_textinput"><input type="text" name="package_price_new[]" class="input_small txt_package_price" /></td>
      <td class="td_textinput"><input type="text" name="package_orderby_new[]" class="input_tiny txt_package_orderby" value="{@orderby}"/></td>
      <td class="td_checkbox"><input type="checkbox" name="package_disabled_new[]"/></td>
      <td class="td_icon"><a class="icon_x20 zmtable_trigger_remove" title="Αφαίρεση"></a></td>
    </tr>
    <tr class="zmtable_tr_no_rows" >
      <td colspan="6">Δεν υπάρχουν καταχωρήσεις</td>
    </tr>
  </tbody>
</table>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 

Preparation code output

# Συσκευασία Τιμή(€) Σειρά x
1 Μέτρο
2 Λίτρο
3 Κιβώτιο
{@ai}
Δεν υπάρχουν καταχωρήσεις

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
getElementsByName
document.getElementsByName("package_price_3");
pending…
jQuery
$("#row_3");
pending…

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

Compare results of other browsers

0 comments

Add a comment