Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lxsmnsyc/import-scheduler
Dynamic import scheduler
https://github.com/lxsmnsyc/import-scheduler
Last synced: 3 months ago
JSON representation
Dynamic import scheduler
- Host: GitHub
- URL: https://github.com/lxsmnsyc/import-scheduler
- Owner: lxsmnsyc
- License: mit
- Created: 2020-11-26T08:50:10.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-21T03:48:43.000Z (about 3 years ago)
- Last Synced: 2024-10-06T11:16:34.241Z (3 months ago)
- Language: TypeScript
- Size: 451 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# import-scheduler
> Dynamic import scheduler
[![NPM](https://img.shields.io/npm/v/import-scheduler.svg)](https://www.npmjs.com/package/import-scheduler) [![JavaScript Style Guide](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
## Install
```bash
yarn add import-scheduler
```## Usage
```ts
import { importForInteractive } from 'import-scheduler';const LazyComponent = lazy(async () => {
await importForInteractive();
return import('./component/lazy');
})
```Kinds of schedulers:
- `importForDisplay()`: Defers dynamic imports until the `document.readyState` becomes `"interactive"` (`"DOMContentLoaded"`).
- `importForInteractive()`: Defers dynamic imports until the `document.readyState` becomes `"complete"` (`"load"`).
- `importForNextFrame()`: Defers dynamic imports until the next frame.
- `importForTimeout(ms)`: Defers dynamic imports until a set timeout.## License
MIT © [lxsmnsyc](https://github.com/lxsmnsyc)