# request-animation-frame-timeout

> setTimeout() via requestAnimationFrame()

Latest version **2.0.4** (published 2024-06-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install request-animation-frame-timeout
pnpm add request-animation-frame-timeout
yarn add request-animation-frame-timeout
bun add request-animation-frame-timeout
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2024-06-04 |
| First published | 2020-09-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 28.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | @catamphetamine |
| Maintainers | catamphetamine |
| Keywords | requestAnimationFrame, setTimeout, timer |

## Links

- npm: https://www.npmjs.com/package/request-animation-frame-timeout
- Repository: https://gitlab.com/catamphetamine/request-animation-frame-timeout
- Homepage: https://gitlab.com/catamphetamine/request-animation-frame-timeout#readme
- Issues: https://gitlab.com/catamphetamine/request-animation-frame-timeout/issues
- npm.io page: https://npm.io/package/request-animation-frame-timeout

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 2.0.4 (latest) — 2024-06-04
- 2.0.3 — 2024-06-03
- 2.0.2 — 2024-06-03
- 2.0.1 — 2024-06-03
- 2.0.0 — 2024-06-03
- 1.0.0 — 2020-09-10

## README

# `request-animation-frame-timeout`

## Rationale

For some weird reason, in Chrome, `setTimeout()` would lag up to a second (or more) behind. Turns out, Chrome developers have deprecated `setTimeout()` API entirely without asking anyone. Replacing `setTimeout()` with `requestAnimationFrame()` can work around that Chrome bug. The timer-freezing behavior of Chrome is inherently retarded, so this workaround wouldn't be required if they designed their corporate web browser properly.

* [Fix Chrome setTimeout throttling](https://github.com/bvaughn/react-virtualized/issues/722)
* [Issue 570845: setInterval and setTimeout stop during input when timer callbacks are expensive](https://bugs.chromium.org/p/chromium/issues/detail?id=570845)

## Use

```
npm install request-animation-frame-timeout --save
```

```js
import { setTimeout, clearTimeout } from 'request-animation-frame-timeout'
```

## Warning

`requestAnimationFrame()` doesn't get called when a web browser tab is not visible (minimized or in background). When a web page goes non-visible, all `requestAnimationFrame()` timers will be paused until the page is visible again. For this reason, `requestAnimationFrame()` timers should only be used for user-interface-related stuff (visual transitions, user input timers, etc).

---
_Source: https://npm.io/package/request-animation-frame-timeout · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
