---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.0
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: https://yandex.com/dev/games/doc/en/sdk/construct-3/throttle-debounce.md
    type: text/markdown
    title: Markdown version
  - href: https://yandex.com/dev/games/doc/en/llms.txt?revision=r21861215
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/en/llms.txt?revision=r21861215

# 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 a part of the game can significantly affect performance. For example, physics or artificial intelligence processing.

Due to the complexity of such computations, it is better to avoid using them too often. For such cases, **Every \<X\> seconds** is usually used to run code once in a while, but this is not always possible.

For example, we have some complex game mechanic that runs when the screen is tapped. In situations like this, when you need to limit the frequency of code execution but cannot use a timer, you can use a special **Not more than once in \<X\> seconds** condition.

{% note warning %}

It is not recommended to use **Not more than once in \<X\> seconds** every tick; this will not have any consequences, but instead it is better to use **Every \<X\> seconds**.

![Construct 3 screenshot: leaderboard configuration screen using the YandexGamesSDK plugin. A table with three columns (each cell in the third column contains "+ Add action" and "+ Add..." buttons) and three rows. Row 1 — "Button", "On clicked", "Yan... | Delay setScore event for 1 second". Row 2 — "YandexGames…", "On delayed event "setScore"", empty cell. Row 3 — "System" settings icon, "authorized true", "Yan... | Send score 10 to leaderboard "score" with data """.](../../_images/construct-3/leaderboards/debounce.webp)

{% endnote %}

## Debounce {#debounce}

Some Yandex Games SDK methods have a limit on the number of requests in a certain period of time. If you neglect these limits, your game may fail moderation.

For example, if you update the leaderboard score too often, you should use a special **On a deferred event** condition together with the trigger condition **Delay execution**. This combination works similarly to the native **Signal** → **On signal** combination, but delays the call for a certain time since the last execution attempt.

However, it can be confused with the previous **Not more than once in \<X\> seconds** condition, because we also used it to hide code that should not be called too often.

The main difference is that **Not more than once in \<X\> seconds** limits the call frequency, while **On a deferred event** delays the function call for a certain time. This is exactly what we need, because we do not necessarily need to run the function too often, we just need to stay within the limit.

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/sdk/button-git.md -->
<a href="https://github.com/yandex-games-plugins/construct3">
  <span class="button">Repository</span>
</a>
<!-- endsource: en/_includes/sdk/button-git.md -->
