Security News
OpenJS: “XZ Utils Cyberattack Likely Not an Isolated Incident”
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
markdown-it-image-lazy-loading
Advanced tools
Weekly downloads
Readme
A markdown-it plugin supporting Chrome 75's native image lazy-loading and async decoding.
$ npm install markdown-it-image-lazy-loading
Load it in ES module.
import markdownit from 'markdown-it';
import lazy_loading from 'markdown-it-image-lazy-loading';
const md = markdownit();
md.use(lazy_loading);
md.render(`![](example.png "image title")`);
// <p><img src="example.png" alt="" title="image title" loading="lazy"></p>\n
Or load it in CommonJS module.
const md = require('markdown-it')();
const lazy_loading = require('markdown-it-image-lazy-loading');
md.use(lazy_loading);
md.render(`![](example.png "image title")`);
// <p><img src="example.png" alt="" title="image title" loading="lazy"></p>\n
If you want the decoding="async"
attribute, enable the plugin's decoding
option.
md.use(lazy_loading, {
decoding: true,
});
md.render(`![](example.png "image title")`);
// <p><img src="example.png" alt="" title="image title" loading="lazy" decoding="async"></p>\n
The plugin can also add width
and height
attributes to each image. This can prevent cumulative layout shifts (CLS):
md.use(lazy_loading, {
image_size: true,
// Where your images are stored
base_path: __dirname + 'src/',
});
md.render(`![](example.png "image title")`);
// <p><img src="example.png" alt="" title="image title" loading="lazy" width="100" height="100"></p>\n
To keep images responsive, also include the following CSS:
img{
max-width: 100%;
height: auto;
}
MIT
FAQs
a markdown-it plugin supporting Chrome 75's native image lazy-loading
The npm package markdown-it-image-lazy-loading receives a total of 3,149 weekly downloads. As such, markdown-it-image-lazy-loading popularity was classified as popular.
We found that markdown-it-image-lazy-loading demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.
Company News
Come meet the Socket team at BSidesSF and RSA! We're sponsoring several fun networking events and we would love to see you there.
Security News
OSI is starting a conversation aimed at removing the excuse of the SaaS loophole for companies navigating licensing and the complexities of doing business with open source.