@junwatu/markdown-it-lazy-loading
v1.0.0-beta.4
Published
This is plugin for markdown-it that add `loading="lazy"` attribute.
Downloads
3
Maintainers
Readme
markdown-it-lazy-loading
This is a plugin for the markdown-it markdown parser.
This plugin add loading="lazy"
attribute to img
or iframe
tag.
Install
npm install @junwatu/markdown-it-lazy-loading --save-dev
How to use
Add lazy
loading attribute to img
tag.
const MarkdownIt = require("markdown-it");
const markdownItLazyLoading = require("@junwatu/markdown-it-lazy-loading");
const mdText = "![ohhh](/some/images/ohhh.png)";
const lzAttr = { img: "lazy" };
const md = MarkdownIt().use(markdownItLazyLoading, lzAttr);
console.log(md.render(mdText));
// <img loading="lazy" href="/some/images/ohhh.png" alt="ohhh">Hello</img>
MIT (c) 2020