https://github.com/lxsmnsyc/import-scheduler
Dynamic import scheduler
https://github.com/lxsmnsyc/import-scheduler
Last synced: about 2 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 (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-21T03:48:43.000Z (over 3 years ago)
- Last Synced: 2025-03-29T10:33:41.062Z (3 months ago)
- Language: TypeScript
- Size: 451 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# import-scheduler
> Dynamic import scheduler
[](https://www.npmjs.com/package/import-scheduler) [](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)