title: how to speed up javascript/jquery for large inventory file?
body: <p>I use a mixture of jquery and javascript to search a bunch of items. 5000+ to be exact. I use a live search feature on my site which filters these items based on keywords. But because there are sooo many items to search through it lags, I would like to speed up this process. </p>
  
  <pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/JavaScript"&gt;
      $(document).ready(function() {
          $("#filter").keyup(function() {
  
              // Retrieve the input field text and reset the count to zero
              var filter = $(this).val(), count = 0;
  
              // Loop through the list
              $(".inventory tr").each(function() {
  
                  // If the list item does not contain the text phrase fade it out
                  if ($(this).text().search(new RegExp(filter, "i")) &lt; 0) {
                      $(this).fadeOut();
  
                      // Show the list item if the phrase matches and increase the count by 1
                  } else {
                      $(this).show();
                      count++;
                  }
              });
  
              // Update the count
              var numberItems = count;
              $("#filter-count").text("Number of items = "+count);
          });
      });
  &lt;/script&gt;
  
  &lt;form id="live-search" action="" class="styled" method="post"&gt;
      &lt;fieldset&gt;
          &lt;input type="text" class="text-input" id="filter" value="" /&gt;
          &lt;span id="filter-count"&gt;&lt;/span&gt;
      &lt;/fieldset&gt;
  &lt;/form&gt;
  
  &lt;div class="inventory"&gt;
      &lt;table&gt; Stuff &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Is there anything I can do to speed it up? I really like this feature and would like to keep it on the site if possible. </p>