MDUIDocs
Copy llms.txt linkCopy llms-full.txt linkView this page in MarkdownDiscuss this page with ChatGPTDiscuss full project docs with ChatGPT
Preset Colors
Custom Color
Extract from Wallpaper
Please select a wallpaper
Getting Started
AI-Assisted Development
Styles
Integration with Frameworks
Components
Functions
jq Library dialog alert confirm prompt snackbar getTheme setTheme getColorFromImage setColorScheme removeColorScheme loadLocale setLocale getLocale throttle observeResize breakpoint
Libraries

throttle

The throttle function creates a throttled function that can be executed at most once within a specified time interval.

Usage

Import the function:

import { throttle } from 'mdui/functions/throttle.js';

Example:

// This function executes at most once within 100 milliseconds, preventing frequent calls during scrolling
window.addEventListener(
  'scroll',
  throttle(() => {
    console.log('update');
  }, 100),
);

API

throttle(func: Function, wait: number): Function

The function accepts two parameters. The first parameter is the function to throttle. The second parameter is the number of milliseconds to delay before the function can be invoked again. The function returns the throttled version of the provided function.

On this page