https://github.com/potatoparser/preact-lazyload
Dead simple lazy loading in preact.
https://github.com/potatoparser/preact-lazyload
Last synced: about 1 year ago
JSON representation
Dead simple lazy loading in preact.
- Host: GitHub
- URL: https://github.com/potatoparser/preact-lazyload
- Owner: PotatoParser
- License: mit
- Created: 2021-10-28T21:21:56.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-28T23:49:26.000Z (over 4 years ago)
- Last Synced: 2025-03-16T03:08:14.193Z (about 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# preact-lazyload
> Dead simple lazy loading in preact.
### Installation
```
npm i preact-lazyload
```
### Usage
```jsx
import { h } from 'preact';
import LazyLoad from 'preact-lazyload';
const App = () => (
Hello World!
);
render(, document.body);
```
Looking for lazy loading images? Although `preact-lazyload` supports all elements, it's better to use [`preact-lazyimage`](https://www.npmjs.com/package/preact-lazyimage)
### Multiple elements
```jsx
import { h } from 'preact';
import LazyLoad from 'preact-lazyload';
const App = () => (
Hello
World!
);
render(, document.body);
```
### Images
```jsx
import { h } from 'preact';
import LazyLoad from 'preact-lazyload';
const App = () => (
{
Array(120).fill("./icon.png").map(img => {
return (
);
})
}
);
render(, document.body);
```