Best way to pre-fetch assets in Lightning?


What is the best way to pre fetch assets and images in lightning?

Could depend on the TV + browser support. I would avoid pre fetching as much as possible for devices that are low powered as it may consume more memory than you’d save.

Lightning components have a boundsMargin property which determine if an item is on screen and will cause Lightning to load the component. So if you have a Row and next item is offScreen - you should set the Rows boundMargin to extend its x to include an additional item for Lightning to load it even though its off screen.

Lastly, you could rely on browser cache and just use “fetch” to call the asset and then load it again in lightning for browser to use the browser cache. Assuming you have the right caching headers on the assets.