I am being bitten by the Chrome / Webkit 71305 error , where hiding a large number of nodes causes Chrome to freeze. (Also happening in Safari).
I am filtering the list item that will be in the drop-down menu with the following:
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 > 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"); } });
Partition markup:
<input type="text" /> <ul> <li> <div> <span title="93252"><label><input type="checkbox">3G</label></span> </div> </li> </ul>
The time required to execute Javascript is negligible. This is when Chrome should redraw the elements after deleting the text in the input that it hangs. Does not occur in FF6 / IE7-9.
I did a JSFiddle to illustrate the problem: http://jsfiddle.net/uUk7S/17/show/
Is there any other approach that I can take instead of hiding and showing elements that cannot damage Chrome? I tried to clone ul by processing in the clone and completely replacing ul in the DOM with the clone, but I hope that there will be a better way, since it is much slower in IE.
optimization javascript jquery google-chrome webkit
Soliah
source share