performance - Will jQuery run faster if the HTML element name is added with the ID? -
below snippet of code use added data table when div clicked on:
$(document).on("click", "div#pos_product_id_<?php echo $row['id']; ?>", function() { $("table#pos_till_products_list").each(function() { searchrow = $(this).find("tr#product_id_<?php echo $row['id']; ?>").html(); if (searchrow == null) { $("#pos_till_products_list tbody:first").prepend("<?php echo $product_build; ?>"); } else { var qty = $(this).find("tr#product_id_<?php echo $row['id']; ?> .qty").html(); qty++; $("tr#product_id_<?php echo $row['id']; ?> .qty").html(qty); } }); }); i'm new using js/jquery, can see i've added html element in front of id's. know if adding html element, make jquery perform faster? think would, adding elements name stops jquery searching other html element id's on page , target html element asked select.
actually, way different frameworks handle selectors impact speeds, impact minimal. take @ slickspeed see benchmark comparison of exhausting array of selector tests, $("body") $("div:nth-child(n)") on number of different frameworks. part, difference matter of millisecond or two, it's interesting thought experiment.
wiki
Comments
Post a Comment