Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

A more performant updateOriginalInput - #1895

Merged
risadams merged 3 commits into
masterfrom
performance/faster-updateOriginalInput
Nov 4, 2022
Merged

risadams merged 3 commits into
masterfrom
performance/faster-updateOriginalInput

Conversation

@risadams

@risadams risadams commented Nov 4, 2022

Copy link
Copy Markdown
Contributor

(Based on #1460)

deefour and others added 3 commits November 4, 2022 05:54
Previously, on every call to updateOriginalInput(), a brand new array of
options for every value in selectize.items would be created and the
entire HTML string would replace all children of the raw input source.

When doing something like

selectize.addItems(_.keys(selectize.options));

for a few hundred options, this becomes very sluggish.

This takes a smarter approach, only removing and adding individual
options from the input source as necessary.

The bottleneck is the repeated use of jQuery's html() method with large
DOM updates. For ~300 options this was originally taking 30154ms in
appendChild. Now it spends only 330.9ms.
@risadams
risadams merged commit c2787e9 into master Nov 4, 2022
@risadams
risadams deleted the performance/faster-updateOriginalInput branch November 4, 2022 10:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants