한국어 | English | 日本語
Senior Web Application Developer (8.8+ years)
Tech & Dev
engineering
Focusing on web frontend and backend development

The Difference Between Throttling and Debouncing

Difference between throttling and debouncing
Throttling and debouncing are solutions to prevent performance issues caused by excessive function calls, such as a browser suffering memory strain from hundreds or thousands of calls when a user scrolls a webpage with a mouse scroll event. To prevent performance degradation due to numerous calls, simply reduce the number of calls. Throttling controls the interval between calls, while debouncing groups multiple calls into a smaller number of calls.

Performance Degradation Issues Due to Excessive Function Calls

Throttling and debouncing are methods to convert numerous calls into a smaller number of calls to solve performance degradation issues caused by excessive calls. If an event is applied to a mouse scroll without any specific constraints in JavaScript, that event will be called excessively numerous times during scrolling. If that event involves heavy operations, it will place a tremendous burden on memory. Throttling and debouncing were devised as solutions to reduce the number of calls in such situations. These techniques are not limited to JavaScript; they can be used in any language or development environment where numerous calls occur in a short period, to convert them into a smaller quantity of calls, thus making them universal concepts.

Strategies to Reduce Excessive Call Volume to a Manageable Level

Throttling and debouncing share the common goal of reducing the number of calls within a given timeframe, but they differ in their approach.

”Intervals” = Throttling

Throttling can be easily understood by thinking of network throttling provided by Chrome Developer Tools to measure page load times under slow network conditions during frontend development. The term ‘throttling’ itself means to reduce the frequency by introducing delays between calls, effectively extending the call interval. Originally, throttling refers to drastically lowering the CPU clock speed in a phone when it overheats, to protect the device. For those who enjoy games or videos, think of ‘frame drops’ where smooth playback suddenly becomes choppy.

Network Throttling

Throttling is used when processing is needed for ‘every action’. Examples include:

”Grouping” = Debouncing

Debouncing appears to originate from circuit engineering. When a switch is turned On/Off, the current flow doesn’t transition cleanly from [ On → Off ]. Instead, there’s a phenomenon of slight vibration, like [ On → Off → On → Off → On → Off ], in a short period. This is called ‘bounce,’ and cleaning up this bounce to a single [ On → Off ] transition is called ‘debouncing.’ It bundles numerous calls into a smaller number of calls.

Debouncing is used when the single fact of ‘whether an action was performed or not’ is important. Examples include:

Summary

In summary, if you want to determine whether a specific action has been performed, you can group calls using debouncing. If you want to recognize all actions but the events are too numerous and you want to reduce their count, you can apply an appropriate delay (interval) with throttling.


  1. The difference between throttling and debouncing
  2. How to optimize web app with debounce and throttle
The Difference Between Throttling and Debouncing
Author
Aaron
Posted on
Licensed Under
CC BY-NC-SA 4.0
CC BY-NC-SA 4.0
More in this category
Recent posts
The Erosion of Conversational Muscle and Communication Styles by LLM Filters
In an era where LLM tools, which filter out conversational impoliteness and deliver refined responses, have become commonplace, are we truly engaging in more thoughtful conversations? This article examines the phenomenon of conversational ability, which should be honed through countless failures in real-time communication, degenerating due to reliance on external tools. It further explores the potential societal anxieties and shifts in generational behavioral patterns that this trend may bring.
Optimal Timing and Strategy for Salary Negotiation with Senior Candidates
Salary negotiation is more than just an exchange of figures; it's a strategic dance of psychological timing. This analysis explores why engaging in a gradual negotiation process from the initial stages of recruitment, rather than waiting until after a final offer (when candidates tend to adopt a more calculative stance), proves more efficient for companies and fosters a more honest sharing of resources.
The Limits of the Rule of Law and Human Diversity
The belief that all human actions can be regulated by a single legal system may be an act of hubris. This article offers a sharp analysis of the paradox of the rule of law faced by humanity, which, having escaped the hierarchical controls of the Middle Ages, has now embraced infinite modern freedom. It further examines the deepening social coercion and the demonization of others that arise under the guise of diversity.
토스트 예시 메세지