Installations
npm install @tjoskar/react-lazyload-img
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
12.8.0
NPM Version
6.10.2
Score
74.5
Supply Chain
95.7
Quality
75.6
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (96.23%)
JavaScript (2.6%)
HTML (1.17%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
46,966
Last Day
106
Last Week
315
Last Month
1,089
Last Year
7,057
GitHub Statistics
MIT License
10 Stars
73 Commits
4 Forks
3 Watchers
5 Branches
3 Contributors
Updated on Jan 14, 2024
Bundle Size
2.69 kB
Minified
1.14 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.2.3
Package Id
@tjoskar/react-lazyload-img@1.2.3
Unpacked Size
2.94 MB
Size
665.02 kB
File Count
43
NPM Version
6.10.2
Node Version
12.8.0
Total Downloads
Cumulative downloads
Total Downloads
46,966
Last Day
58.2%
106
Compared to previous day
Last Week
-1.6%
315
Compared to previous week
Last Month
31.8%
1,089
Compared to previous month
Last Year
-8.3%
7,057
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
react-lazyload-img

Lazy image loader for react
Install
$ npm install @tjoskar/react-lazyload-img
Usage
1import React, { Component } from 'react' 2import { LazyLoadImage, LazyLoadBackgroundImage } from '@tjoskar/react-lazyload-img' 3 4const App = () => { 5 const defaultImage = 'https://www.placecage.com/1000/1000' 6 const image = 'https://images.unsplash.com/photo-1443890923422-7819ed4101c0?fm=jpg' 7 return ( 8 <> 9 { /* To use an img-tag */ } 10 <LazyLoadImage width={50} height="200px" defaultImage={this.defaultImage} image={this.image} /> 11 12 { /* To use a div-tag with background image styling */ } 13 <LazyLoadBackgroundImage width="100%" height="200px" defaultImage={this.defaultImage} image={this.image} /> 14 </> 15 ) 16}
You can also pass options (root
, rootMargin
, threshold
) to the IntersectionObserver constructor. See the documentation for IntersectionObserver for more info. Eg.
1<LazyLoadImage options={{ root: window }} height="200px" defaultImage={this.defaultImage} image={this.image} />
See: https://stackblitz.com/edit/react-lazy-load-image for examples
Props
Both LazyLoadImage
and LazyLoadBackgroundImage
have the same props:
defaultImage
Type: string
Path to the default image (placeholder) to show before the lazy loading
image
Type: string
Default: 60
Path to the image to be lazy loaded
errorImage?
Type: string
Path to an image to show if the loading of image
fails, will use defaultImage
if not set
onLoaded?
Type: () => void
Callback function after the image has been loaded
options?
Type: ObserverOptions
IntersectionObserver options. https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#Intersection_observer_options
style?
Type: React.CSSProperties
Will be passed to the underlying div/img tag
height
Type: () => void
The height of the image (can be set to auto
)
width
Type: () => void
The width of the image (can be set to auto
)
Requirement
The browser you are targeting needs to have support for IntersectionObserver
and WeakMap
or you need to import polyfill for them. You also need to use a bundler that understand es-modules (eg. webpack, rollup, parcel, fusebox, etc.)
License
MIT

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 6/14 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 22 are checked with a SAST tool
Reason
69 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-257v-vj4p-3w2h
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2
- Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-7r28-3m3f-r2pr
- Warn: Project is vulnerable to: GHSA-r8j5-h5cx-65gg
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-92xj-mqp7-vmcj
- Warn: Project is vulnerable to: GHSA-wxgw-qj99-44c2
- Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5
- Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp
- Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq
- Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr
- Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765
- Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-566m-qj78-rww5
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-876r-hj45-fw7g
- Warn: Project is vulnerable to: GHSA-v63x-xc9j-hhvq
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-w5q7-3pr9-x44w
- Warn: Project is vulnerable to: GHSA-3fjq-93xj-3f3f
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
2.3
/10
Last Scanned on 2025-02-03
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