Replace lodash.debounce with a much smaller, custom debounce function #6550
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Replace lodash.debounce with a much smaller, custom debounce function
Pull Request Type
Description
Lodash's debounce function has served us well but it is quite old so contains a lot of polyfills, also has various options that we don't use in FreeTube and uses the CommonJS module syntax so it doesn't get fully optimised in our builds. This pull request replaces it with a custom, simpler debounce function saving us 1577 bytes in the
renderer.js
build.The debounce function is based on the one provided here: https://you-dont-need.github.io/You-Dont-Need-Lodash-Underscore/#/?id=_debounce
For comparision here is the JavaScript of
lodash.debounce
copied from thenode_modules
folder with the comments removed so that this isn't too long (it is still rather large, compared to the 17 line (with comments) function that we have now):Click to expand
Testing
Enable Search Suggestions
is turned on in the general settings(you are basically checking that it does the same as before)
Desktop