Reducing Load Time of Large selectizeInput

I have an app with numerous (10+) selectizeInput()s each with 20,000+ choices. I have identified that these are the reason why my app currently takes ~30 seconds to load. All selectizeInputs appear on the second tab of a shinyDashboard, so users won't be interacting with them immediately when the app launches.

I would like to reduce launch time/lag as much as possible.

I have already:

  1. Moved the initialization of choices into the server as below, where new_choices is a single-column dataframe.
#UI: 
selectizeInput("id","label", choices = NULL)
#Server:
updateSelectizeInput(session,"id", choices = new_choices)
  1. Attempted to set server = TRUE within updateSelectizeInput, but this results in a search-box that does not respond to any typing, as documented here:
    https://github.com/rstudio/shiny/issues/1963

Any ideas if (2) above would actually speed things up? What is the expected behavior when we've set server=TRUE?

Is there a way to asynchronously load the UI elements that are not needed immediately on launch such that users can still interact with the app instead of waiting for all UI elements to load? I wouldn't want this to be triggered by an observeEvent that would just shift where the delay occurs. Rather, I'd want the UI elements to load while users interact with the first tab, so they are ready to go when they advance to the second tab.

Thank you!

Hi,

Could you give some more details on what's in the selectizeInput that needs >20,000 choices? Maybe it would be better if you changed the whole procedure to something where a user types in (part of) a choice, then clicks a button, filtering is done on the server side and only the matches are displayed in a UI element then can be further refined. This would be much faster...

There might be ways to asynchronously load all choices, but I think we should also consider alternatives as above. But for that I need some more info :slight_smile:

Kind regards,
PJ