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

Files: 
CommentFileSizeAuthor
#4 core-js-one-debounce-to-rule-them-all-1889394-4.patch3.61 KBnod_
PASSED: [[SimpleTest]]: [MySQL] 55,522 pass(es).
[ View ]
#3 debounce.patch3.63 KBdroplet
PASSED: [[SimpleTest]]: [MySQL] 53,587 pass(es).
[ View ]

Comments

sobi3ch’s picture

Title:Choose ONE JS debounce function» Choose one JS debounce function
Status:Active» Postponed (maintainer needs more info)

What 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.

droplet’s picture

Status:Postponed (maintainer needs more info)» Active

It'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.

droplet’s picture

Status:Active» Needs review
StatusFileSize
new3.63 KB
PASSED: [[SimpleTest]]: [MySQL] 53,587 pass(es).
[ View ]
nod_’s picture

StatusFileSize
new3.61 KB
PASSED: [[SimpleTest]]: [MySQL] 55,522 pass(es).
[ View ]

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.

nod_’s picture

Status:Needs review» Reviewed & tested by the community

minor changes to #3 (just adding brackets) and #3 is RTBC.

alexpott’s picture

Status:Reviewed & tested by the community» Fixed

Committed 74b5b36 and pushed to 8.x. Thanks!

hass’s picture

Why is immediate in (func, wait, immediate) not wait = 0? Telling the function to wait 0 milliseconds is like executing immediately, isn't it?

nod_’s picture

It's code from underscore.js, from their comments: If `immediate` is passed, trigger the function on the leading edge, instead of the trailing.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.