Much Debouncing
Sep 29 2023The Challenge
In the life cycle of a <much-select> a lot of events are triggered. Events can trigger additional events leading to big cascades of events that can block the main browser thread. We can prevent this from happening with debouncing.
Two example of this in <much-select>:
- Each
keypresswhen a user is filtering down a list of options. If we debouncekeypressevents by a half a second or so the UI looks smoother and we do a lot less work. - Updating the options in the
<much-select>following a relevant DOM change. However, DOM changes can come in in rapid succession. Waiting a 10th of a second or so, for changes to stabilize/finish before updating the options saved a lot of work.
Changes and re-renders in the DOM can be costly. Reducing their frequency significantly improves the responsiveness of <much-select> and enables it to manage larger lists of options more efficiently.