Gathering detailed insights and metrics for ngx-progressive-image-loader
Gathering detailed insights and metrics for ngx-progressive-image-loader
Gathering detailed insights and metrics for ngx-progressive-image-loader
Gathering detailed insights and metrics for ngx-progressive-image-loader
lazy load img/picture, prevent reflow and seo friendly.
npm install ngx-progressive-image-loader
Typescript
Module System
TypeScript (74.15%)
HTML (13.13%)
JavaScript (9.15%)
CSS (3.57%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
35 Stars
118 Commits
6 Forks
2 Watchers
30 Branches
2 Contributors
Updated on Apr 26, 2021
Latest Version
4.0.0
Package Id
ngx-progressive-image-loader@4.0.0
Unpacked Size
376.05 kB
Size
77.94 kB
File Count
63
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
2
2
Support Angular >=6.0.0
No other JS dependency. Just Angular
Use IntersectionObserver to determine the timing to load the image
Support image and picture
Preserve space to avoid dom reflow
Show small default loading image with fading transition
Load image directly for spider (SEO friendly) or non-supported browsers
Aggressive Loading. Able to continue to load even if images haven't got intersected when the concurrently loading count is lower than a certain value. (after 4.0.0)
1npm install ngx-progressive-image-loader --save
Open your module file e.g app.module.ts
and update imports array
1import { NgxProgressiveImageLoaderModule, IImageLoaderOptions } from 'ngx-progressive-image-loader'; 2... 3imports: [ 4... 5 NgxProgressiveImageLoaderModule.forRoot(<IImageLoaderOptions>{ 6 // rootMargin must be specified in pixels or percent 7 rootMargin: '30px', 8 threshold: 0.1, 9 // css filter 10 filter: 'blur(3px) drop-shadow(0 0 0.75rem crimson)', 11 // image width / height ratio for image holder 12 imageRatio: 16 / 9, 13 // loading image in placeholder. Can be URL or base64 14 placeholderImageSrc: 15 // tslint:disable-next-line:max-line-length 16 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICA8cGF0aCBmaWxsPSIjZGQwMDMxIiBkPSJNMTI1IDMwTDMxLjkgNjMuMmwxNC4yIDEyMy4xTDEyNSAyMzBsNzguOS00My43IDE0LjItMTIzLjF6Ii8+CiAgPHBhdGggZmlsbD0iI2MzMDAyZiIgZD0iTTEyNSAzMHYyMi4yLS4xVjIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMUwxMjUgMzB6Ii8+CiAgPHBhdGggZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiBmaWxsPSIjZmZmIi8+Cjwvc3ZnPgo=' 17 }) 18... 19]
Add style to your global scss
1@import '~ngx-progressive-image-loader/ngx-progressive-image-loader'; 2 3$scale: 0.5; // the scale of loading image in place holder 4$transition: opacity 1s linear; // the transition of loading image in place holder, you could try: opacity .3s ease 5@include progressive-image-loader($scale, $transition);
1<ngx-progressive-image-loader> 2 <ngx-image-placeholder> 3 <!-- ngx-image-placeholder is optional --> 4 <img [src]="'/assets/Avengers1.jpg'" alt="" ngxProgressiveImage /> 5 </ngx-image-placeholder> 6 <img src="/assets/Avengers2.jpg" alt="" ngxProgressiveImage /> 7</ngx-progressive-image-loader>
1<ngx-progressive-image-loader> 2 <img 3 [src]="'/assets/Avengers6.jpg'" 4 [srcset]="'/assets/Avengers6.jpg 800w,/assets/Avengers7.jpg 1366w'" 5 size="(max-width: 1000px) 100vw, 100vw" 6 ngxProgressiveImage 7 /> 8</ngx-progressive-image-loader>
1<ngx-progressive-image-loader> 2 <picture ngxProgressiveImage> 3 <source [srcset]="'/assets/Avengers4.jpg'" media="(max-width: 1000px)" /> 4 <source [srcset]="'/assets/Avengers5.jpg'" media="(min-width: 1000px)" /> 5 <img [src]="'/assets/Avengers4.jpg'" alt="My default image" /> 6 </picture> 7</ngx-progressive-image-loader>
root The element that is used as the viewport for checking visiblity of the target. Must be the ancestor of the target. Defaults to the browser viewport if not specified or if null.
rootMargin
Margin around the root. Can have values similar to the CSS margin property, e.g. "10px 20px 30px 40px" (top, right, bottom, left). The values can be percentages. This set of values serves to grow or shrink each side of the root element's bounding box before computing intersections. Defaults to all zeros.
threshold
Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed. If you only want to detect when visibility passes the 50% mark, you can use a value of 0.5. If you want the callback run every time visibility passes another 25%, you would specify the array [0, 0.25, 0.5, 0.75, 1]. The default is 0 (meaning as soon as even one pixel is visible, the callback will be run). A value of 1.0 means that the threshold isn't considered passed until every pixel is visible.
filter
If you want to set more filter. It uses the input string as css filter.
placeholderImageSrc
src for loading image. It works just like src, takes base64 or url.
imageRatio
image width / height
For ngx-image-placeholder
component, it takes
imageRatio
placeholderImageSrc
(after 3.0.0, you can set imageRatio and placeholderImageSrc directly on ngxProgressiveImage
and spare ngx-image-placeholder layer)
For ngx-progressive-image-loader
component, it takes
imageRatio
placeholderImageSrc
filter
isAggressiveLoading: boolean; default to true
; Set to true
to enable Aggressive Loading feature. (after 4.0.0)
concurrentLoading: number; default t0 4; Decided at least how many concurrent loading when Aggressive Loading is enabled
For ngxProgressiveImage
directive, (only for image or source elements)
imageRatio
placeholderImageSrc
noPlaceholder: boolean; default to false
, set to true
will skip image placeholder
1npm i 2 3npm run build
To run demo code locally
npm run start
Browsers don't support Intersection Observer API will not work as expect. It will load images like old time.
Use pollyfill like below might make it work.
1<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
Please ask your general questions at https://stackoverflow.com
This project was generated with Angular CLI version 6.2.0 beta 02.
Kudos to the following authors:
https://deanhume.com/lazy-loading-images-using-intersection-observer/
https://www.voorhoede.nl/en/blog/say-no-to-image-reflow/
https://jmperezperez.com/medium-image-progressive-loading-placeholder/
https://github.com/verlok/lazyload for detecting spider
And my wife and my child to let me work on a weekend for this.
Big thanks to BrowserStack for letting the maintainers use their service to debug browser issues.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/4 approved changesets -- score normalized to 2
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
137 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