Minimising the load size for pages with slideshows or multiple images
The development page for the automatic loading of an image from an array was getting a little out of hand.
The next step is to develop a method to generate a random number to load the random image.
In my development so far I have learnt a bit about the scoping of variables (var, const and let). I had to create variables with unique names when I had similar routines on the same page. The image at the top of this page is id = image-container2.
The index of the image in the array to be displayed is hard-coded. This is intended to be a random number between 0 and 1 less than the length of the array containing the images.
I also need an array that contains the size (width) to be used by the image-container.
15 August 2026 - I quite the idea of having the ability to have a random image on any of my pages. In fact possibly more thaan one.
The code for this could even be placed in portfolio.css. I have put a random image on about_3.html and the home page - I will see how this goes.
Random Image
The script displays an image from an array.
The script is on the source code below:
The index of the image from the array is set in the script.