Luiz
Luiz

Reputation: 43

How optimizing Selectize Performance by Centralizing Options Lists?

I'm using the Selectize library and facing a challenge. The page I'm building repeatedly creates the same "select" element with a large list of options, which affects performance. These elements are added dynamically when the page loads.

I want to know if it's possible to link the options list of the duplicated inputs to a "central list" to avoid rendering multiple "selectize-dropdown-content" with the same content. I've researched extensively but couldn't find an easy solution. If necessary, I can create a plugin, although I'm not familiar with the library.

Example:

const Options = [
  { value: 'option1', text: 'Opção 1' },
  { value: 'option2', text: 'Opção 2' },
];

$('#select1').selectize({
  options: Options,
});

$('#select2').selectize({
  options: Options,
});

Result:

enter image description here

These are the same options, no need to load them repeatedly. Ideally, the only resource to maintain would be the uniqueness of each select, such as input, cache...

Upvotes: 0

Views: 24

Answers (0)

Related Questions