How to preload a list of differently named image files

Use an array to store the names of the various image names and use the for loop to iterate through the array, creating new instances for each.

How do we do this?

We create a dillemna with this objective. Say we have ten images and we want to randomly select four of them. A JavaScript solution would involve downloading all ten, even though only four will be chosen. They have to be present or we can’t display them.

I’m only now wrapping my head around how we could generate code client side that would have random source attributes but I’m not clicking on anything. PHP handles this, no problem, server side. The random src values are written to the response document. Piece of cake.


Still thinking on this one, but I think there is a way. Just need to spend more time thinking on it. It has to be in the build phase so the script will be in the HEAD. Some thought needed to piece this together.