All Projects → ivodolenc → Nuxt Lazysizes

ivodolenc / Nuxt Lazysizes

Licence: mit
Lazysizes module for Nuxt.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Nuxt Lazysizes

nuxt-speedkit
nuxt-speedkit will help you to improve the lighthouse performance score (100/100) of your website.
Stars: ✭ 401 (+1504%)
Mutual labels:  nuxt, lazy-loading, nuxtjs
Nuxt Dev To Clone
Build DEV.TO clone with Nuxt.js and new `fetch` hook
Stars: ✭ 118 (+372%)
Mutual labels:  nuxt, nuxtjs, lazy-loading
Composition Api
Composition API hooks for Nuxt.
Stars: ✭ 441 (+1664%)
Mutual labels:  nuxt, nuxtjs
Wuxt
Nuxt/WordPress development environment, combining the worlds biggest CMS with the most awesome front-end application framework yet.
Stars: ✭ 459 (+1736%)
Mutual labels:  nuxt, nuxtjs
Vue Lazy Hydration
Lazy Hydration of Server-Side Rendered Vue.js Components
Stars: ✭ 797 (+3088%)
Mutual labels:  nuxt, nuxtjs
Nuxt Optimized Images
🌅🚀 Automatically optimizes images used in Nuxt.js projects (JPEG, PNG, SVG, WebP and GIF).
Stars: ✭ 717 (+2768%)
Mutual labels:  nuxt, nuxtjs
Device Module
Nuxt.js module for detecting device type.
Stars: ✭ 436 (+1644%)
Mutual labels:  nuxt, nuxtjs
Style Resources Module
Nobody likes extra @import statements!
Stars: ✭ 485 (+1840%)
Mutual labels:  nuxt, nuxtjs
Awesome Nuxt
A curated list of awesome things related to Nuxt.js
Stars: ✭ 4,285 (+17040%)
Mutual labels:  nuxt, nuxtjs
Sitemap Module
Sitemap Module for Nuxt
Stars: ✭ 539 (+2056%)
Mutual labels:  nuxt, nuxtjs
Firebase Module
🔥 Easily integrate Firebase into your Nuxt project. 🔥
Stars: ✭ 493 (+1872%)
Mutual labels:  nuxt, nuxtjs
Wemake Vue Template
Bleeding edge vue template focused on code quality and developer happiness.
Stars: ✭ 645 (+2480%)
Mutual labels:  nuxt, nuxtjs
Vanilla Lazyload
LazyLoad is a lightweight, flexible script that speeds up your website by deferring the loading of your below-the-fold images, backgrounds, videos, iframes and scripts to when they will enter the viewport. Written in plain "vanilla" JavaScript, it leverages IntersectionObserver, supports responsive images and enables native lazy loading.
Stars: ✭ 6,596 (+26284%)
Mutual labels:  lazy-loading, lazyload
Vercel Builder
Vercel Builder for Nuxt.js
Stars: ✭ 437 (+1648%)
Mutual labels:  nuxt, nuxtjs
Vuecnodejs
⚽️🎉Vue初/中级项目,CnodeJS社区重构。( a junior project of Vue.js, rewrite cnodejs.org ) 预览(DEMO):
Stars: ✭ 705 (+2720%)
Mutual labels:  nuxt, nuxtjs
Vue Gallery
📷 Responsive and customizable image and video gallery, carousel and lightbox, optimized for both mobile and desktop web browsers.
Stars: ✭ 405 (+1520%)
Mutual labels:  nuxt, nuxtjs
Nuxt Firebase Sns Example
Nuxt v2 & Firebase(Hosting / Functions SSR / Firestore), Google Auth SNS Example.
Stars: ✭ 485 (+1840%)
Mutual labels:  nuxt, nuxtjs
React Lazy Load Image Component
React Component to lazy load images and components using a HOC to track window scroll position.
Stars: ✭ 755 (+2920%)
Mutual labels:  lazy-loading, lazyload
Vue Notion
A fast Vue renderer for Notion pages
Stars: ✭ 343 (+1272%)
Mutual labels:  nuxt, nuxtjs
Nuxt Purgecss
Drop superfluous CSS! A neat PurgeCSS wrapper for Nuxt.js
Stars: ✭ 356 (+1324%)
Mutual labels:  nuxt, nuxtjs

Nuxt LazySizes

LazySizes module for Nuxt.js

Features

  • Helps you integrate lazysizes loader
  • Allows you to easily set options through the module
  • Includes settings that can be used to extend the Nuxt build loader
  • Boosts your lighthouse score and overall performance 🔥
  • Provides a lightweight, fast and reliable solution
  • Supports options to enable additional plugins
  • Zero-config setup ready to go 🚀

Quick Start

  1. Add nuxt-lazysizes dependency to your project
$ npm install --save-dev nuxt-lazysizes # or yarn add --dev nuxt-lazysizes
  1. Add nuxt-lazysizes to the buildModules section of nuxt.config.js
// nuxt.config.js

export default {
  buildModules: ['nuxt-lazysizes'],

  lazySizes: {
    /* module options */
  }
}

That's it! Start developing your app ✨

Examples

💻 Here are some code examples

Basic usage

Lazysizes does not need any configuration. Add the class lazyload to your images/iframes in combination with a data-src and/or data-srcset attribute.

// nuxt.config.js

{
  buildModules: ['nuxt-lazysizes'],
}
<img data-src="/media/image.jpg" class="lazyload" />

More info

Advanced usage (optional)

By default, loading images from the assets folder won't work without extra settings because lazysizes uses custom attributes for lazyloading.

<!-- This won't work -->

<img :data-src="require('~/assets/media/image.jpg')" class="lazyload" />

✅ To fix this problem, the module provides extendAssetUrls option that can be used to extend the Nuxt build loader and define custom tags with new attributes:

// nuxt.config.js

{
  buildModules: ['nuxt-lazysizes'],

  lazySizes: {
    extendAssetUrls: {
      img: ['src', 'srcset', 'data-src', 'data-srcset'],
      source: ['src', 'srcset', 'data-src', 'data-srcset'],

      // Example for a custom component
      AppImage: ['source-md-url', 'image-url'],
    },
  }
}

After defining the extendAssetUrls option, loading images from the assets folder will work as expected 👌

Non-responsive example

<img data-src="~/assets/media/image.jpg" class="lazyload" />

Responsive example

<figure>
  <picture>
    <source
      data-srcset="~/assets/media/image-md.jpg"
      media="(min-width:700px)"
    />
    <img data-src="~/assets/media/image.jpg" class="lazyload" />
  </picture>
</figure>

Custom component example

<AppImage
  source-md-url="~/assets/media/image-md.jpg"
  image-url="~/assets/media/image.jpg"
/>

Extra plugins (optional)

The module also supports options to enable additional plugins, so you can easily extend and adjust lazysizes to your needs.

By default, all plugins are set to false.

Plugins example

// nuxt.config.js

{
  lazySizes: {
    plugins: {
      blurUp: true,
      nativeLoading: true,
      unveilhooks: true,
    }
  }
}

More info

Options

Lazysizes automatically detects new elements with the class lazyload so you won't need to call or configure anything in most situations.

Default options

// nuxt.config.js

{
  lazySizes: {
    extendAssetUrls: undefined,
    plugins: {
      blurUp: false,
      nativeLoading: false,
      unveilhooks: false
    },

    // LazySizes JS API
    lazyClass: 'lazyload',
    loadedClass: 'lazyloaded',
    loadingClass: 'lazyloading',
    preloadClass: 'lazypreload',
    errorClass: 'lazyerror',
    autosizesClass: 'lazyautosizes',
    fastLoadedClass: 'ls-is-cached',
    iframeLoadMode: 0,
    srcAttr: 'data-src',
    srcsetAttr: 'data-srcset',
    sizesAttr: 'data-sizes',
    minSize: 40,
    customMedia: {},
    init: true,
    expFactor: 1.5,
    hFac: 0.8,
    loadMode: 2,
    loadHidden: true,
    ricTimeout: 0,
    throttleDelay: 125
  }
}

More info

Blur-Up plugin

  • Default: false
// nuxt.config.js

{
  lazySizes: {
    plugins: {
      blurUp: true
    },

    // Default 'blurUp' settings
    blurUpClass: 'ls-blur-up-img',
    blurUpLoadingClass: 'ls-blur-up-is-loading',
    blurUpInviewClass: 'ls-inview',
    blurUpLoadedClass: 'ls-blur-up-loaded',
    blurUpLoadedOriginalClass: 'ls-original-loaded'
  }
}

More info

Native loading plugin

  • Default: false
// nuxt.config.js

{
  lazySizes: {
    plugins: {
      nativeLoading: true
    },

    // Default 'nativeLoading' settings
    nativeLoading: {
      setLoadingAttribute: false,
      listenerMap: {
        focus: 1,
        mouseover: 1,
        click: 1,
        load: 1,
        transitionend: 1,
        animationend: 1,
        scroll: 1,
        resize: 1
      },
      disableListeners: undefined
    }
  }
}

More info

Unveilhooks plugin (data-bg)

  • Default: false
// nuxt.config.js

{
  lazySizes: {
    plugins: {
      unveilhooks: true
    },
  }
}

More info

License

LazySizes

MIT License

Copyright (c) Alexander Farkas

Nuxt LazySizes Module

MIT License

Copyright (c) Ivo Dolenc

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].