1.0.0-beta.4 • Published 4 years ago

@junwatu/markdown-it-lazy-loading v1.0.0-beta.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

markdown-it-lazy-loading

Node.js CI Node.js Package

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