# preact-lazyimage

> Lazy image loading made easy and simple for preact.

Latest version **0.0.5** (published 2022-04-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install preact-lazyimage
pnpm add preact-lazyimage
yarn add preact-lazyimage
bun add preact-lazyimage
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2022-04-07 |
| First published | 2021-10-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Wilson Nguyen |
| Maintainers | potatoparser |
| Keywords | lazy, lazyload, lazy loading, lazy image, lazyimage, preact |

## Links

- npm: https://www.npmjs.com/package/preact-lazyimage
- Repository: https://github.com/PotatoParser/preact-lazyimage
- Homepage: https://github.com/PotatoParser/preact-lazyimage#readme
- Issues: https://github.com/PotatoParser/preact-lazyimage/issues
- npm.io page: https://npm.io/package/preact-lazyimage

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2022-04-07
- 0.0.4 — 2022-01-17
- 0.0.3 — 2022-01-15
- 0.0.2 — 2021-10-28
- 0.0.1 — 2021-10-28

## README

# preact-lazyimage
> Lazy image loading made easy and simple for preact.

### Installation
```
npm i preact-lazyimage
```

#### Drop In Replacement!
```jsx
// Old
<img src="./image"></img>

// Replace with:

// Lazy Image Loading
<LazyImg src="./image"></LazyImg>
```

### Usage
```jsx
import { h } from 'preact';

import LazyImg from 'preact-lazyimage';

const App = () => <LazyImg style={{width: '40px', height: '40px'}} src="./icon.png"></LazyImg>;

render(<App/>, document.body);
```

Looking for lazy loading other elements? Check out [`preact-lazyload`](https://www.npmjs.com/package/preact-lazyload)

### Properties
```jsx
<LazyImg
  onLoad={imgElement => {}}   // Triggered when image loads
  onUnload={imgElement => {}} // Triggered when image unloads
  delay={0}                   // Delay lazy loading in milliseconds
  cache={true}                // Enable/Disable caching of images; true by default
  src={src}                   // Set source for image
  legacy={false}              // Use getBoundingClientRect instead of IntersectionObservers
  preloadWidth={0}            // Preload the images with an offset width, legacy must be set to `true`
  preloadHeight={0}           // Preload the images with an offset height, legacy must be set to `true`
  {...props}                  // Remaining properties are applied onto the image element
></LazyImg>
```

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