3.0.4 ā€¢ Published 1 year ago

nuxt-lazy-load v3.0.4

Weekly downloads
10,636
License
MIT
Repository
gitlab
Last release
1 year ago

nuxt-lazy-load

npm i nuxt-lazy-load

npm version npm downloads npm downloads

šŸ‘‰ Description

You don't need to bother with extra attributes on elements (like data-src and data-srcset), just add the module in nuxt.config.js and that's it

āš ļø For Nuxt 2, use nuxt-lazy-load < 3.0.0

šŸš€ Usage

// nuxt.config.js (nuxt.config.ts)
modules: [
  'nuxt-lazy-load'
]

šŸ”§ Options

modules: [
  'nuxt-lazy-load'
],

lazyLoad: {
  // These are the default values
  images: true,
  videos: true,
  audios: true,
  iframes: true,
  native: false,
  directiveOnly: false,
  
  // Default image must be in the public folder
  defaultImage: '/images/default-image.jpg',

  // To remove class set value to false
  loadingClass: 'isLoading',
  loadedClass: 'isLoaded',
  appendClass: 'lazyLoad',
  
  observerConfig: {
    // See IntersectionObserver documentation
  }
}

directiveOnly

If you don't want to use lazy load on every image/video/audio/iframe, set directiveOnly to true and use directive like this (with data-src/data-srcset/data-poster)

<img data-src="image.png" alt="" title="" v-lazy-load>

You don't need to add directive (v-lazy-load) on source elements

<video data-poster="~/assets/images/poster.jpg" v-lazy-load>
  <source data-src="video.mp4" type="video/mp4"> --> without directive
</video>

data-not-lazy

If you don't want to lazy load single element, just add data-not-lazy attribute

<audio controls="controls" data-not-lazy>
  <source type="audio/mpeg" src="audio.mp3">
</audio>

Buy me a coffee

ko-fi

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

1.3.0

1 year ago

1.2.8

3 years ago

1.2.9

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.1

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.0.0

5 years ago