Hi there
I’m trying to find the way to lazy load image component on LightningJS, but only find lazyCreate
in the documentation. Have anyone done this and willing to share to suggestion?
Main goal is trying to improve image load on page load. Thanks!
Few ways to do this.
-
Be lazy with component creation. Say you have a Tile component loaded into rows and you show 5 rows on the page at a time. Add a row each time you Keydown - then the tiles will be created and load the images automatically. Creating less components + loading less images is double win.
-
There is also an
_active
hook that you can use to load the image when the component is on screen (should only be triggered when in view port)
LightningJS.io - Documentation
This could be as simple asimgsrc = 'someurl', when active set
src = this.imgsrc`;
Thanks @chiefcll for quick response. I’m going to test them out. Thanks again!