Have ideas to improve npm?Join in the discussion! »

markdown-it-image-lazysizes

1.0.0 • Public • Published

markdown-it-image-lazysizes

A markdown-it plugin to support lazy loading of images using lazysizes.

The plugin makes lazyload possible by:

  • Move src to data-src
  • Add class lazyload to img tag.

lazysizes has to be installed to make this plugin work.

Install

npm i -D markdown-it-image-lazysizes
npm i -D lazysizes

Usage

const md = require('markdown-it')();
const lazy_loading = require('markdown-it-image-lazysizes');
md.use(lazy_loading);
 
md.render(`![](example.png "image title")`);
// <p><img alt="" title="image title" class="lazyloading" data-src="example.png"></p>\n

Add the lazysize javascript:

<script src="lazysizes.min.js" async></script>

Related Information

Contribution

This is a minimum plugin. Please open an issue when you need more functionalities or something doesn't work!

Install

npm i markdown-it-image-lazysizes

DownloadsWeekly Downloads

160

Version

1.0.0

License

MIT

Unpacked Size

2.53 kB

Total Files

4

Last publish

Collaborators

  • avatar