---
metadata:
  - name: generator
    content: Diplodoc Platform v5.54.4
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/construct-3/throttle-debounce.md
  - https://yandex.com/dev/games/doc/hi/sdk/construct-3/throttle-debounce.md
  - https://yandex.com/dev/games/doc/ko/sdk/construct-3/throttle-debounce.md
  - https://yandex.com/dev/games/doc/ru/sdk/construct-3/throttle-debounce.md
  - https://yandex.com/dev/games/doc/tr/sdk/construct-3/throttle-debounce.md
  - https://yandex.com/dev/games/doc/vi/sdk/construct-3/throttle-debounce.md
  - https://yandex.com/dev/games/doc/zh/sdk/construct-3/throttle-debounce.md
  - href: en/sdk/construct-3/throttle-debounce.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/en/llms.txt

# Throttle and Debounce

<!-- source: en/_includes/script-common.md -->
<!-- source: en/_includes/script/index-js.md -->

<!-- endsource: en/_includes/script/index-js.md -->

<!-- source: en/_includes/script/requirements-js.md -->

<!-- endsource: en/_includes/script/requirements-js.md -->

<!-- source: en/_includes/script/image-modal-js.md -->

<!-- endsource: en/_includes/script/image-modal-js.md -->
<!-- endsource: en/_includes/script-common.md -->

The plugin provides access to two special conditions: **Not more than once in \<X\> seconds** and **On a deferred event**.

If you prefer JavaScript, you can refer to the articles: [Debounce example with a search form](https://doka.guide/js/debounce/){.external} and [Throttle example with page updates on scroll](https://doka.guide/js/throttle/){.external}.



## Throttle {#throttle}

Sometimes certain parts of a game can heavily impact overall performance. For example, physics processing or AI calculations.

Due to the complexity of such computations, it's better to avoid running them too frequently. For such cases, people often use **Every \<X\> seconds** to execute code every X seconds. However, this isn't always possible.

Imagine a complex game mechanic that runs when the screen is tapped. In situations where you need to limit how often code executes but can't use a timer, the **Not more than once in \<X\> seconds** condition comes in handy.

{% note warning %}

Avoid using **Not more than once in \<X\> seconds** on every tick. While it won't cause errors, it's better to use **Every \<X\> seconds** instead in such cases.

![](../../_images/construct-3/leaderboards/debounce.webp)

{% endnote %}



## Debounce {#debounce}

Some methods in the Yandex Games SDK have rate limits for API requests. Exceeding these limits might lead to your game failing moderation.

For example, if you update a leaderboard score too frequently, you should use the **On a deferred event** condition in combination with the **Delay execution** trigger condition. This combination works similarly to the native **Signal** → **On signal** pair, but delays the call for a specific time from the last execution attempt.

However, it can be confused with the **Not more than once in \<X\> seconds** condition since both prevent functions from being called too often. What's the difference?

The key distinction is that **Not more than once in \<X\> seconds** limits how often a function can run, while **On a deferred event** delays the function execution until a certain time has passed. This is exactly what we need for leaderboard updates — we don't need constant updates, just compliance with rate limits.

Visualization of the difference between **Not more than once in \<X\> seconds** and **On a deferred event**:

@[youtube](https://www.youtube.com/embed/gFpNtZ2lPM8?si=R3DgcZEtsShirW4n)


---


<!-- source: en/_includes/button-git.md -->
<a href="https://github.com/yandex-games-plugins/construct3">
  <span class="button">Repository</span>
</a>
<!-- endsource: en/_includes/button-git.md -->
