@nuxt-modules/lazy-load

Lazy load module for Nuxt 3
1,592 28
Install
npm install @nuxt-modules/lazy-load
Latest Version:0.2.0
License:MIT
Last Updated:Jan 31, 2022
Links: GitHub  ·  npm
Maintainer: baroshem

@nuxt-modules/lazy-load

@nuxt-modules/lazy-load

npm version npm downloads Github Actions CI Codecov License

Lazy Loading Images module for Nuxt 3

Features

  • Nuxt 3 ready
  • Easy Lazy Loading Images, Pictures, and other HTML elements
  • Advanced configuration using Lozad.js
  • Handy composable useLazyLoad
  • TypeScript support

📖  Read the documentation

Setup

yarn add @nuxt-modules/lazy-load # yarn
npm i @nuxt-modules/lazy-load # npm

Basic usage

Firstly, you need to add @nuxt-modules/lazy-load to your Nuxt config.

// nuxt.config.js

{
  buildModules: [
    ['@nuxt-modules/lazy-load']
  ]
}

Then you can start using @nuxt-modules/lazy-load in your setup function!

<script setup lang="ts">
const { init } = useLazyLoad();

onMounted(() => {
  init()
})
</script>

Lastly, let's add a lazy class and change src attribute to data-src

<img class="lazy" data-src="https://path-to-image.jpg"/>

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using yarn dev or npm run dev

License

MIT License

Related Packages

@nuxtjs/critters

Critical CSS for Nuxt

594,605 189
@nuxt-modules/compression

Compression module for Nuxt 3

46,675 32
nuxt-beastcss

Fast Critical CSS for Nuxt

21,758
nuxt-workers

Easily run code in web workers in Nuxt.

52,258 447
nuxt-define

One utility function for module authors to define compiler constants for all bui...

13,412,511

Version History

Version Released License
0.2.0 MIT
0.1.0 MIT