Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashkyd/jankdefer
An experiment to defer executing until the framerate in the page stabilizes
https://github.com/ashkyd/jankdefer
Last synced: 2 months ago
JSON representation
An experiment to defer executing until the framerate in the page stabilizes
- Host: GitHub
- URL: https://github.com/ashkyd/jankdefer
- Owner: AshKyd
- Created: 2017-06-21T23:53:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-15T12:29:57.000Z (almost 2 years ago)
- Last Synced: 2024-10-14T15:09:23.612Z (3 months ago)
- Language: JavaScript
- Size: 44.9 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
jankdefer 🖥🔥
=============It's like [domready](https://www.npmjs.com/package/domready), except it defers loading until the page framerate stabilizes. The
idea is that if requestAnimationFrame is running slowly, then the page has
either not loaded yet or the page is in a background tab.This script ensures requestAnimationFrame runs at least 50fps for several frames
before calling back.See also: [requestIdleCallback|https://developer.mozilla.org/en-US/docs/Web/API/Window/requestIdleCallback]
Usage
-----Basic usage should be good enough for most scenarios:
```
const jankdefer = require('jankdefer');jankdefer(myFunction);
```Usage with options:
```
const jankdefer = require('jankdefer');jankdefer(myFunction, {
framerateTarget: 50,
timeout: 3000,
threshold: 5,
debug: false,
});
```Default options
-------------Property | Default | Description
----------------|---------|---------------------
framerateTarget | 50 | Wait until the system is running at least 50fps. (Some slower devices do not run at 60)
timeout | 3000 | Number of milliseconds after which the function will run anyway.
threshold | 5 | Wait at least this many successful runs before calling back.
debug | false | Print debug info if you want to understand what's happening.