# metalsmith-native-lazy-loading

> A metalsmith plugin for adding browser native lazy loading to images

Latest version **0.9.4** (published 2021-03-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install metalsmith-native-lazy-loading
pnpm add metalsmith-native-lazy-loading
yarn add metalsmith-native-lazy-loading
bun add metalsmith-native-lazy-loading
```

## 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.9.4 |
| Published | 2021-03-15 |
| First published | 2021-03-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tony Gustafsson |
| Maintainers | legon |

## Links

- npm: https://www.npmjs.com/package/metalsmith-native-lazy-loading
- Repository: https://github.com/tonygustafsson/metalsmith-native-lazy-loading
- Homepage: https://github.com/tonygustafsson/metalsmith-native-lazy-loading#readme
- Issues: https://github.com/tonygustafsson/metalsmith-native-lazy-loading/issues
- npm.io page: https://npm.io/package/metalsmith-native-lazy-loading

## Dependencies (2)

- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.5
- [metalsmith-debug](https://npm.io/package/metalsmith-debug.md) ^1.2.0

## Recent versions

- 0.9.4 (latest) — 2021-03-15
- 0.9.3 — 2021-03-15
- 0.9.2 — 2021-03-15
- 0.9.0 — 2021-03-11

## README

# Metalsmith Native Lazy Loading

## What is Metalsmith?

It's a great static site generator that is often used to create HTML from Markdown and other markup languages.

More info: https://metalsmith.io/

## Why this plugin?

There are other plugins that adds lazy loading to images, but this one uses the simplest approach - browser native image lazy loading. From this:

```
<img src="img/my-image.jpg" alt="MyAlt" title="MyTitle">
```

To this:

```
<img loading="lazy" src="img/my-image.jpg" alt="MyAlt" title="MyTitle">
```

Check browser compability: https://caniuse.com/loading-lazy-attr

## How to install

```javascript
npm install --save-dev metalsmith-native-lazy-loading
```

## How to use

Add this to the top:

```javascript
var imageLazyLoading = require('metalsmith-native-lazy-loading');
```

You then use it like so;

```javascript
Metalsmith(__dirnam).use(
    imageLazyLoading({
        pattern: ['**/*.html'],
    })
);
```

That's all there is to it.

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