Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi
Chosen library versions 1.5.0+ have handy new option "max_shown_results" which can improve chosen widget performance significantly in cases of select lists with very many options. Here is quote from Chosen library documentation:
max_shown_results
Only show the first (n) matching options in the results. This can be used to increase performance for selects with very many options.
Default value: Infinity
It would be nice to add such option to drupal Chosen module and test and ensure that Drupal Chosen module works nicely with 1.5.0+ version of Chosen library.
Comments
Comment #2
soyjaz CreditAttribution: soyjaz as a volunteer commentedOne "dirty" way to do it is by modifying directly in the chosen.jquery.min.js file at libraries/chosen.
CTRL+F for this.max_shown_results
Comment (or remove) the existing this.options.max_shown_results||Number.POSITIVE_INFINITY
Replace by your value, e.g. 10 :
this.max_shown_results=10/*this.options.max_shown_results||Number.POSITIVE_INFINITY*/
Not a clean way but gets the job done.
Of course, such option only exists with chosen versions above 1.5.0.
Comment #3
Chris CharltonI believe this is already in the Chosen settings/options?