user984621 February 2016

Select tag with many items takes time to render

I have a form with a select tag containing nearly 17k items.

<%= :company_industry_id, options_for_select({
 |c| [,] }, selected_key = @company.company_industry_id),
 {}, {:class => 'input_text'} %>

Loading data for @company_industries takes like 0.01s.

@company_industries =, :name).order('name ASC')

However, rendering it in the box takes about 18 seconds (without having this element in the form, the page is rendered in 350-400ms).

How do I avoid this slowdown? Is there a way to optimize the element? Or, is there some alternative to


Nermin February 2016

I would suggest select2

And best approach would be to not load data immediately, but when user types in 3 letters, then you show the data filtered with those 3 letters. It also gives you nice way to search trough you 17k elements, to faster find result.

Post Status

Asked in February 2016
Viewed 1,227 times
Voted 9
Answered 1 times


Leave an answer