Gathering detailed insights and metrics for nuxt-lazysizes
Gathering detailed insights and metrics for nuxt-lazysizes
Gathering detailed insights and metrics for nuxt-lazysizes
Gathering detailed insights and metrics for nuxt-lazysizes
npm install nuxt-lazysizes
Typescript
Module System
Node Version
NPM Version
69.6
Supply Chain
88.8
Quality
78.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
44 Stars
51 Commits
1 Forks
2 Watchers
1 Branches
1 Contributors
Updated on Mar 21, 2024
Latest Version
1.4.3
Package Id
nuxt-lazysizes@1.4.3
Unpacked Size
11.20 kB
Size
3.68 kB
File Count
5
NPM Version
9.6.4
Node Version
18.12.1
Published on
May 15, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
3
Lazysizes module for Nuxt 2.
lazysizes
loaderloader
lightweight
, fast
and reliable
solutionplugins
Zero-config
setup ready to go 🚀nuxt-lazysizes
dependency to your project1$ yarn add -D nuxt-lazysizes # or npm i -D nuxt-lazysizes
nuxt-lazysizes
in the buildModules
section1// nuxt.config.js 2 3export default { 4 buildModules: ['nuxt-lazysizes'], 5 6 lazySizes: { 7 /* Module Options */ 8 } 9}
That's it! Start developing your app!
Here are some code examples
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.
1// nuxt.config.js 2 3export default { 4 buildModules: ['nuxt-lazysizes'] 5}
1<img data-src="/media/image.jpg" class="lazyload" />
By default, loading images from the assets
folder won't work without extra settings because lazysizes uses custom attributes for lazyloading.
1<!-- This won't work --> 2 3<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:
1// nuxt.config.js 2 3export default { 4 buildModules: ['nuxt-lazysizes'], 5 6 lazySizes: { 7 extendAssetUrls: { 8 img: ['src', 'srcset', 'data-src', 'data-srcset'], 9 source: ['src', 'srcset', 'data-src', 'data-srcset'], 10 11 // Example for a custom component 12 AppImage: ['source-md-url', 'image-url'] 13 } 14 } 15}
After defining the extendAssetUrls
option, loading images from the assets
folder will work as expected 👌
Non-responsive example
1<img data-src="~/assets/media/image.jpg" class="lazyload" />
Responsive example
1<figure> 2 <picture> 3 <source 4 data-srcset="~/assets/media/image-md.jpg" 5 media="(min-width:700px)" 6 /> 7 8 <img data-src="~/assets/media/image.jpg" class="lazyload" /> 9 </picture> 10</figure>
Custom component example
1<AppImage 2 source-md-url="~/assets/media/image-md.jpg" 3 image-url="~/assets/media/image.jpg" 4/>
The module also supports options to enable additional plugins
, so you can easily extend and adjust lazysizes to your needs.
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 plugins: { 6 blurUp: true, 7 nativeLoading: true, 8 bgset: true 9 } 10 } 11}
Lazysizes automatically detects new elements with the class lazyload
so you won't need to call or configure anything in most situations.
Defaults
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 extendAssetUrls: undefined, 6 plugins: { 7 blurUp: false, 8 nativeLoading: false, 9 unveilhooks: false, 10 parentFit: false, 11 rias: false, 12 optimumx: false, 13 customMedia: false, 14 bgset: false 15 }, 16 17 // LazySizes JS API 18 lazyClass: 'lazyload', 19 loadedClass: 'lazyloaded', 20 loadingClass: 'lazyloading', 21 preloadClass: 'lazypreload', 22 errorClass: 'lazyerror', 23 autosizesClass: 'lazyautosizes', 24 fastLoadedClass: 'ls-is-cached', 25 iframeLoadMode: 0, 26 srcAttr: 'data-src', 27 srcsetAttr: 'data-srcset', 28 sizesAttr: 'data-sizes', 29 minSize: 40, 30 customMedia: {}, 31 init: true, 32 expFactor: 1.5, 33 hFac: 0.8, 34 loadMode: 2, 35 loadHidden: true, 36 ricTimeout: 0, 37 throttleDelay: 125 38 } 39}
false
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 plugins: { 6 blurUp: true 7 }, 8 9 // Default 'blurUp' settings 10 blurUpClass: 'ls-blur-up-img', 11 blurUpLoadingClass: 'ls-blur-up-is-loading', 12 blurUpInviewClass: 'ls-inview', 13 blurUpLoadedClass: 'ls-blur-up-loaded', 14 blurUpLoadedOriginalClass: 'ls-original-loaded' 15 } 16}
false
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 plugins: { 6 nativeLoading: true 7 }, 8 9 // Default 'nativeLoading' settings 10 nativeLoading: { 11 setLoadingAttribute: false, 12 listenerMap: { 13 focus: 1, 14 mouseover: 1, 15 click: 1, 16 load: 1, 17 transitionend: 1, 18 animationend: 1, 19 scroll: 1, 20 resize: 1 21 }, 22 disableListeners: undefined 23 } 24 } 25}
false
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 plugins: { 6 unveilhooks: true 7 } 8 } 9}
false
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 plugins: { 6 parentFit: true 7 } 8 } 9}
false
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 plugins: { 6 rias: true 7 }, 8 9 // Rias defaults 10 rias: { 11 prefix: '', 12 postfix: '', 13 srcAttr: 'data-src', 14 absUrl: false, 15 modifyOptions: noop, 16 widthmap: {}, 17 ratio: false, 18 traditionalRatio: false, 19 aspectratio: false, 20 widths: [] 21 } 22 } 23}
false
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 plugins: { 6 optimumx: true 7 } 8 } 9}
false
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 plugins: { 6 customMedia: true 7 }, 8 9 customMedia: {} 10 } 11}
false
1// nuxt.config.js 2 3export default { 4 lazySizes: { 5 plugins: { 6 bgset: true 7 } 8 } 9}
LazySizes
Copyright (c) Alexander Farkas
Nuxt LazySizes
Copyright (c) Ivo Dolenc
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More