The process involves, creating an Array to hold images , the src attribute is assigned any one of the images from the array.
The demo below is another version of the previous example, it replaces images based on User Input.
There is always some delay involved while downloading images from the server, and on slow networks the delay is even more prominent
This issue can be resolved by using an Image() Constructor, which enables you to preload images, and put in browser's cache before it is put to use. This caching technique vastly improves the response time.
Even the size of the cached image(width and height) can be set, but the Image() constructor must be kept in the head element only.
Images can be displayed randomly using Math Object random(), the attribute src gets images at random using this method.