Skip to content

a markdown-it plugin to better supporting image lazy loading

License

Notifications You must be signed in to change notification settings

tolking/markdown-it-img-lazy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-it-img-lazy

a markdown-it plugin to better supporting image lazy loading

The plugin will preferentially use native image lazy-loading, if the browser does not support it, it will be implemented through lozad


Installation

yarn add markdown-it-img-lazy
# or
npm i markdown-it-img-lazy

Usage

md.use(require('markdown-it-img-lazy'), /* Options */)

then you need

load Lozad.js in the head tag of your page

load imgLazy.js closer the </body> tag of your page

![img](/img.jpg)

Options

useNative

  • Type: Boolean
  • Default: true
  • Required: false

Use the native image lazy-loading for the web

if useNative = true
![img](img.jpg) -> <p><img alt="img" data-src="img.jpg" loading="lazy" class="lazy"></p>

if useNative = false
![img](img.jpg) -> <p><img alt="img" data-src="img.jpg" class="lazy"></p>

selector

  • Type: string
  • Default: lazy
  • Required: false

Default class name for image

prefix

  • Type: string Function
  • Default: ''
  • Required: false

Config prefix for src in images

About

a markdown-it plugin to better supporting image lazy loading

Resources

License

Stars

Watchers

Forks

Packages

No packages published