-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngOptions slow in IE with large arrays #12076
Comments
A 500+ element array being bound to a select element sounds like a bad idea from a UX standpoint. |
Meeting with the same issue in IE. Per ng-options source code, we know currently Angular is trying to reuse DOM elements to reduce unnecessary DOM redraw.
But can we leverage documentFragments when try to append new elements
Then we can avoid the performance hit when select options vastly change. @wesleycho @Narretz pls let me know if this is acceptable. I tested on my machine with 1000 items in select options, using |
Can you open a PR that uses documentFragment when appending new elements (without deleting option elements) |
I ran into this exact same issue today with IE11. I had to remove my page's dropdowns from Angular's supervision and populate them using JQuery, instead, to get good speed on IE. ngRepeat was a lot faster than ngOptions (~3 seconds vs ~10, respectively) for two dropdowns with ~500 items each, but the JQuery approach takes less than a second. It's a shame to have to wire the dropdowns manually just to be fast on IE. |
Hopefully, this can be resolved soon, but here's a hack that defers DOM creation to JQuery for simple lists:
This speeds up execution ~100x (2 minutes without versus a little over a second with) for a list 4000 items long. Judging by the path jQuery takes in IE11, generating the list with document fragments is a viable way to go, but I'm not familiar enough to create a real, long-term pull-request to fix. |
@quantumwannabe solution worked great for me with ie11x64 - 11.0.10586.0 |
This changes the way option elements are generated when the ngOption collection changes. Previously, we would re-use option elements when possible (updating their text and label). Now, we first remove all currently displayed options and the create new options for the collection. The new options are first appended to a documentFragment, which is in the end appended to the selectElement. Using documentFragment improves render performance in IE with large option collections (> 100 elements) considerably. Always creating new options fixes issues in IE where the select would become unresponsive to user input. Fixes angular#13607 Fixes angular#12076
This changes the way option elements are generated when the ngOption collection changes. Previously, we would re-use option elements when possible (updating their text and label). Now, we first remove all currently displayed options and the create new options for the collection. The new options are first appended to a documentFragment, which is in the end appended to the selectElement. Using documentFragment improves render performance in IE with large option collections (> 100 elements) considerably. Always creating new options fixes issues in IE where the select would become unresponsive to user input. Fixes angular#13607 Fixes angular#12076
This changes the way option elements are generated when the ngOption collection changes. Previously, we would re-use option elements when possible (updating their text and label). Now, we first remove all currently displayed options and the create new options for the collection. The new options are first appended to a documentFragment, which is in the end appended to the selectElement. Using documentFragment improves render performance in IE with large option collections (> 100 elements) considerably. Always creating new options fixes issues in IE where the select would become unresponsive to user input. Fixes angular#13607 Fixes angular#12076
This changes the way option elements are generated when the ngOption collection changes. Previously, we would re-use option elements when possible (updating their text and label). Now, we first remove all currently displayed options and the create new options for the collection. The new options are first appended to a documentFragment, which is in the end appended to the selectElement. Using documentFragment improves render performance in IE with large option collections (> 100 elements) considerably. Always creating new options fixes issues in IE where the select would become unresponsive to user input. Fixes angular#13607 Fixes angular#13239 Fixes angular#12076
This changes the way option elements are generated when the ngOption collection changes. Previously, we would re-use option elements when possible (updating their text and label). Now, we first remove all currently displayed options and the create new options for the collection. The new options are first appended to a documentFragment, which is in the end appended to the selectElement. Using documentFragment improves render performance in IE with large option collections (> 100 elements) considerably. Creating new options from scratch fixes issues in IE where the select would become unresponsive to user input. Fixes angular#13607 Fixes angular#13239 Fixes angular#12076
This changes the way option elements are generated when the ngOption collection changes. Previously, we would re-use option elements when possible (updating their text and label). Now, we first remove all currently displayed options and the create new options for the collection. The new options are first appended to a documentFragment, which is in the end appended to the selectElement. Using documentFragment improves render performance in IE with large option collections (> 100 elements) considerably. Creating new options from scratch fixes issues in IE where the select would become unresponsive to user input. Fixes angular#13607 Fixes angular#13239 Fixes angular#12076
This changes the way option elements are generated when the ngOption collection changes. Previously, we would re-use option elements when possible (updating their text and label). Now, we first remove all currently displayed options and the create new options for the collection. The new options are first appended to a documentFragment, which is in the end appended to the selectElement. Using documentFragment improves render performance in IE with large option collections (> 100 elements) considerably. Creating new options from scratch fixes issues in IE where the select would become unresponsive to user input. Fixes #13607 Fixes #13239 Fixes #12076
Thank you for that fix. Rendering of one of my pages with a few fat selects now takes 3 sec on angular 1.5.5 instead of 80 sec on angular 1.5.3. Appreciate it. |
oh yes, thank you ! |
Hi, |
I have the same issues where dropdowns are very slow in IE. I have used the below plunker (http://plnkr.co/edit/ULtEHtcD5La4Ax7hd5kY?p=preview) but got stuck with one more issue.
I checked while debugging got to know that model name is not populating as well. please help on this. |
I have a 500+ element array which I want to bind to a
<select>
element.In Chrome, this works fine, adding the array takes a fraction of a second.
In IE, it takes multiple seconds to add the array, during which time the UI is unresponsive.
Looking at timelines, it appears that Chrome recalculates styles after all
<option>
elements are added, but IE calculates styles and layouts after each<option>
is added.Chrome:


IE:
Maybe using
documentFragments
could fix this?Plunker: http://plnkr.co/edit/ULtEHtcD5La4Ax7hd5kY?p=preview
The text was updated successfully, but these errors were encountered: