Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There are 3 debounce function in the CORE.
#1. misc/debounce.js
#2. misc/matchmedia.js
#3. misc/underscore/underscore.js
#1 & 2, 99.999% identity
#1, 2 & 3 = 99% identity
Comment | File | Size | Author |
---|---|---|---|
#4 | core-js-one-debounce-to-rule-them-all-1889394-4.patch | 3.61 KB | nod_ |
#3 | debounce.patch | 3.63 KB | droplet |
Comments
Comment #1
sobi3ch CreditAttribution: sobi3ch commentedWhat do you mean by "choose one"? There is misc/debounce.js made strictly for Drupal so it's seems is already chosen. If you thinking about removing them from other libraries then it can be hard to do it because they are part of those libraries.
Comment #2
droplet CreditAttribution: droplet commentedIt's not true, we can copy & paste underscore code and add Drupal namespace. Also, matchmedia is not vendor lib, no reason to duplicated same function twice.
When you work on own project that base on other Loader, you can exclude to load the scripts if they are all identity functions.
Comment #3
droplet CreditAttribution: droplet commentedComment #4
nod_Thanks to #1974580: Introduce domReady to remove jQuery dependency from drupal.js and clean it up. we can do that. The problem was that the dependency required jQuery down the line. Not anymore.
Also debounce.js is our file, no need to violate our coding standards.
Comment #5
nod_minor changes to #3 (just adding brackets) and #3 is RTBC.
Comment #6
alexpottCommitted 74b5b36 and pushed to 8.x. Thanks!
Comment #7
hass CreditAttribution: hass commentedWhy is immediate in
(func, wait, immediate)
notwait = 0
? Telling the function to wait 0 milliseconds is like executing immediately, isn't it?Comment #8
nod_It's code from underscore.js, from their comments:
If `immediate` is passed, trigger the function on the leading edge, instead of the trailing.