Skip to main content

@mdit/plugin-img-lazyload


Plugin to add lazy loading for images.

Usage

TS
import MarkdownIt from "markdown-it";
import { imgLazyload } from "@mdit/plugin-img-lazyload";

const mdIt = MarkdownIt().use(imgLazyload);

mdIt.render("![Image](https://example.com/image.png)");

Description

The plugin automatically add loading="lazy" to all images to let them being lazy loaded.

Note

This is a native HTML5 feature, so your browser must support loading=lazy attributeopen in new window.