Gathering detailed insights and metrics for ngx-lazy-load-images
Gathering detailed insights and metrics for ngx-lazy-load-images
Gathering detailed insights and metrics for ngx-lazy-load-images
Gathering detailed insights and metrics for ngx-lazy-load-images
@jfkz/ngx-lazy-load-images
Image lazy load library for Angular 2+.
@doughlass/ngx-lazy-load-images
Image lazy load library for Angular 15+.
ngx-picture
An Angular library to properly size, lazy load images, and use next generation formats
ngx-lazy-loading-images
An Angular library that lazy load images with IntersectionObserver API
npm install ngx-lazy-load-images
Typescript
Module System
Node Version
NPM Version
TypeScript (81.74%)
JavaScript (18.26%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
80 Stars
57 Commits
19 Forks
1 Watchers
23 Branches
3 Contributors
Updated on Feb 18, 2024
Latest Version
2.0.0
Package Id
ngx-lazy-load-images@2.0.0
Unpacked Size
134.86 kB
Size
30.09 kB
File Count
23
NPM Version
6.14.11
Node Version
12.14.0
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
ngx-lazy-load-images is a image lazy load library for Angular 2+.
The library allows to lazy load images from your web application using the MutationObserver and the IntersectionObserver. Images will be loaded as soon as they enter the viewport in a non-blocking way.
It supports <img>
tags as well as background images.
You can install the library via npm with this command:
npm install ngx-lazy-load-images --save
LazyLoadImagesModule
Import LazyLoadImagesModule
from the ngx-lazy-load-images
package, and add it to the NgModule
imports array of your component.
1import { NgModule } from '@angular/core'; 2import { LazyLoadImagesModule } from 'ngx-lazy-load-images'; 3 4@NgModule({ 5 imports: [ 6 LazyLoadImagesModule 7 ] 8}) 9export class AppComponent {}
lazy-load-images
directiveAdd the lazy-load-images
directive to the tag containing all the DOM image nodes to lazy load:
1<!-- Image tags --> 2<div class="image-list" lazy-load-images> 3 <img *ngFor="let imageUrl in images" [attr.data-src]="imageUrl"> 4</div> 5 6<!-- Background images --> 7<div class="image-list" lazy-load-images> 8 <div *ngFor="let imageUrl in images" [attr.data-background-src]="imageUrl"></div> 9</div>
The container can have any HTML or components inside along with the images. But the less nodes inside the directive, the faster it will be.
Intersection Observer Configuration
If you want to make some configuration changes to the Intersection Observer, you can do it by passing an object to the lazy-load-images
directive. The object takes the Intersection Observer configuration parameters as keys.
1<div class="image-list" [lazy-load-images]="{ rootMargin: '50px' }"></div>
data-src
or data-background-src
attributeSet the data-src
or data-background-src
attribute in the images or tags that you want to lazy load.
The data-src
attribute allows to lazy load images inside <img>
tags. You can define it by passing a variable to the attribute, interpolating a variable, or inserting the URL directly:
1<img [attr.data-src]="imageUrlVariable"> 2<img attr.data-src="{{ imageUrlVariable }}"> 3<img data-src="https://example.com/cute_kitten.jpg">
The data-background-src
attribute lazy loads background images inside any HTML tag. It works the same way as the data-src
attribute:
1<div [attr.data-background-src]="imageUrlVariable"></div> 2<div attr.data-background-src="{{ imageUrlVariable }}"></div> 3<div data-background-src="https://example.com/cute_kitten.jpg"></div>
Will this module make my web application worse in terms of performance?
What happens if I have lots of images, will it consume too much memory?
This library has been tested and known to work in the latest version of all major browsers.
The WICG Intersection Observer Polyfill is bundled within the module to use the Intersection Observer API in the non-compatible browsers. Avoid importing it in your application too, as it may cause unexpected issues.
However, the compatibility with older browsers is limited by the Mutation Observer
support, which is known to work in:
![]() 26+ |
![]() 14+ |
![]() 6+ |
![]() ✔ |
![]() 11+ |
![]() 15+ |
![]() 4.4+ |
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/29 approved changesets -- score normalized to 0
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
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
118 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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