0.9.4 • Published 3 years ago

metalsmith-native-lazy-loading v0.9.4

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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

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

How to use

Add this to the top:

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

You then use it like so;

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

That's all there is to it.

0.9.4

3 years ago

0.9.3

3 years ago

0.9.2

3 years ago

0.9.0

3 years ago