---
title: "Idle Decorator"
description: "The @idle decorator wraps a method in Async.requestIdleCallback so heavy work runs during browser idle time without blocking the main thread or overflowing the stack."
metadata:
  - name: keywords
    content: "jodit idle, requestidlecallback, decorator, async, main thread, performance"
---
# @idle

Wrap function in [Async.requestIdleCallback](https://xdsoft.net/jodit/docs/classes/async.Async.html#requestidlecallback) wrapper

```ts
import { component, idle } from 'jodit/core/decorators';
import { UIElement } from 'jodit/ui';

@component
class SomeClass extends UIElement {
  @idle
  runIdle(): void {
    // Do some havy work
    this.runIdle(); // This will work and won't go into stack depth error and break the main thread
  }
}
```


### idle()

**idle**\<`V`\>(): [`DecoratorHandler`](./types.html#decoratorhandler)

Defined in: [src/core/decorators/idle/idle.ts:18](https://github.com/xdan/jodit/blob/main/src/core/decorators/idle/idle.ts#L18)

#### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
| `V` *extends* [`IComponent`](../interfaces/types.IComponent.html)\<[`IViewBased`](../interfaces/types.IViewBased.html)\<[`IViewOptions`](../interfaces/types.IViewOptions.html)\>\> | [`IComponent`](../interfaces/types.IComponent.html)\<[`IViewBased`](../interfaces/types.IViewBased.html)\<[`IViewOptions`](../interfaces/types.IViewOptions.html)\>\> |

#### Returns

[`DecoratorHandler`](./types.html#decoratorhandler)
