Note that there are some explanatory texts on larger screens.

plurals
  1. POWork around for live filtering 1500+ items with jQuery in Chrome
    text
    copied!<p>I'm being bitten by the Chrome/Webkit <a href="http://code.google.com/p/chromium/issues/detail?id=71305" rel="nofollow">71305</a> bug where un-hiding a large number of nodes causes Chrome to hang. (Also occurs in Safari).</p> <p>I am filtering a list item that will be in a drop down menu with the following:</p> <pre><code>jQuery.expr[':'].Contains = function(a, i, m) { return $.trim((a.textContent || a.innerText || "")).toUpperCase().indexOf(m[3].toUpperCase()) == 0; }; var input = $('input'); var container = $('ul'); input.keyup(function(e) { var filter = $.trim(input.val()); if (filter.length &gt; 0) { // Show matches. container.find("li:Contains(" + filter + ")").css("display", "block"); container.find("li:not(:Contains(" + filter + "))").css("display", "none"); } else { container.find('li').css("display", "block"); } }); </code></pre> <p>Snippet of the markup:</p> <pre><code>&lt;input type="text" /&gt; &lt;ul&gt; &lt;li&gt; &lt;div&gt; &lt;span title="93252"&gt;&lt;label&gt;&lt;input type="checkbox"&gt;3G&lt;/label&gt;&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>The time it takes for the Javascript to execute is negligible. It's when Chrome needs to redraw the elements after deleting the text in the <code>input</code> that it hangs. Does not happen in FF6/IE7-9.</p> <p>I made a JSFiddle to illustrate the issue: <a href="http://jsfiddle.net/uUk7S/17/show/" rel="nofollow">http://jsfiddle.net/uUk7S/17/show/</a></p> <p>Is there another approach I can take rather than hiding and showing the elements that will not cause Chrome to hang? I have tried cloning the <code>ul</code>, processing in the clone and replacing the <code>ul</code> in the DOM completely with the clone, but am hoping there's a better way as this is significantly slower in IE.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload