What VirtualScroll
is all about:
The basic idea is that we only create enough elements in the DOM to display the list data that is currently on screen, and we recycle those DOM elements to display new data as they scroll off screen.
The benefits from using VirtualScroll
are huge in terms of performance.
DOM can be really heavy when you have 1000 items rendered not to mention the danger of a possible memory crash.
What ion-img
does :
The ion-img component is similar to the standard img element, but it also adds features in order to provide improved performance. Features include only loading images which are visible, using web workers for HTTP requests, preventing jank while scrolling and in-memory caching.
Also:
with ion-img the app is able to dedicate resources to just the viewable images
The benefits from this approach are also huge towards a better performance because images that are not viewable are not going to be rendered.
And last:
ion-img
has a property named cache
After an image has been successfully downloaded, it can be cached
in-memory. This is useful for VirtualScroll by allowing image
responses to be cached, and not rendered, until after scrolling has
completed, which allows for smoother scrolling.`
You can set this property accordingly.
I will try to enrich my answer even further, please suggest me anything i have missed or anything that is unclear.
sources:
https://ionicframework.com/docs/api/components/img/Img/,
https://ionicframework.com/docs/api/components/virtual-scroll/VirtualScroll/,
https://www.joshmorony.com/boosting-scroll-performance-in-ionic-2/