# throttle-lazy-load

> Simple & light weight (

Latest version **1.0.2** (published 2019-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install throttle-lazy-load
pnpm add throttle-lazy-load
yarn add throttle-lazy-load
bun add throttle-lazy-load
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-03-31 |
| First published | 2019-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 999.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | hellozfy16@163.com |
| Maintainers | zhoufeiyu |
| Keywords | javascript, lazy, image, scroll, css, html |

## Links

- npm: https://www.npmjs.com/package/throttle-lazy-load
- npm.io page: https://npm.io/package/throttle-lazy-load

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-03-31
- 1.0.1 — 2019-03-31
- 1.0.0 — 2019-03-31

## README

# lazy-load
Simple & light weight (<3kb gzipped) vanilla javascript plugin to lazy load.

## DEMO

## Getting Started
### NPM Setup
```npm install throttle-lazy-load```
```import Lazy from 'throttle-lazy-load/lib/Lazy.js'```
### Basic Browser Setup
1. Add lazy to your html
```<script src='./lib/Lazy.js'>```
2. Initialize the plugin
```
Lazy.create().start({})
```
3. add attribute to the HTML tags you want to lazy-load
```
<img lazy-img='xxx.jpg'>
```
4. lazy load 
## custom
### interval
You can pass options into your custom lazy load.
```
Lazy.create().lift({fn: () => new time, num: 300}).start({})
```
This can make your lazy load throttle 300s.

### extend
```
Lazy.create({extend: 200})
```
This can make your lazy load extend 200px.
### attribute
```
Lazy.create({attr: 'data-img'})
```
This can make your lazy load attribute for 'data-img
### el && event
```
Lazy.create().start({el: button, event: 'click'})
```
This can make your lazy load for bottom addEventListener click

## release memory
### removeEventListener
when start listen, you can execute this to removeEventListener
```
const lazy = Lazy.create().start({el: button, event: 'click'})
lazy() // removeEventListener
```

### destory
```
const lazy = Lazy.create()
lazy.destory() // destory remove elements/listeners/interval
```

ToDo
1. demo
2. Intersection Observer API design
3. code cleanup
4. typescript support

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