I have about a hundred of simple SVG images, which are stored in about five different image folders. Currently, when they are needed to be displayed, they are retrieved right then. This, for the most part, works, but it does sometimes cause flickering, which I would like to eliminate. Is there a way to preload these images prior to when they are needed, so that they would be cached? I've seen some solutions on here, but they mainly deal with a small number of images. Is there a preferred way of doing a high volume preload?
Thanks!
If you have all the URLs of the images you can start to cache them as soon as possible in a JS object using the url, and later just fetch them from there when you need them.
In your page you may have the list of SVG images stored in somewhere, but at the end what you need is just a JS array of URLs string.
Here's a quick example:
Note:
img.onerror
and serve in case some "missing" image as replacementHere is a css solution: