Socket
Socket
Sign inDemoInstall

nuxt3-lazy-load

Package Overview
Dependencies
148
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    nuxt3-lazy-load

Nuxt 3 Lazy Load


Version published
Weekly downloads
203
decreased by-11.35%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

nuxt3-lazy-load

npm i nuxt3-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 😊

🚀 Usage

// nuxt.config.js (nuxt.config.ts)
modules: [
  'nuxt3-lazy-load'
]
// or
modules: [
  ['nuxt3-lazy-load', {
    // Your options
  }]
]

Buy me a coffee

ko-fi

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>

🔧 Options

modules: [
  ['nuxt3-lazy-load', {
    // 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
    }
  }]
]

Keywords

FAQs

Last updated on 11 Apr 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc