Preloading of pictures
Sometimes, during development of a site, there is a situation when it is necessary to use some images on page which poocheredi replace each other, thus the page is not updated. For this purpose preloading of images which allows is used will be loaded to images right at the beginning of the body text of page.
Actually, preloading is carried out surprisingly simply. Right at the beginning of page the small script is inserted:
<script language=JavaScript>
pic = new Image ();
pic.src = "test.jpg";
</script>
Where test-jpg - a preloaded picture which is not displayed on page, but at any moment of her{it} it is possible to display without additional expectation of loading of the image.
I shall result enough a simple example, that you would understand, what for in general it is necessary to use preloading of images:
<script language=JavaScript>
pic = new Image ();
pic.src = "sea_2.jpg";
</script>
<img src = "sea_1.jpg" style ='cursor: hand ' onclick ='this.src=pic.src '>
<img src = "sea_1.jpg" style ='cursor: hand ' onclick ='this.src = "sea_3.jpg" '>
Images sea_2.jpg and sea_3.jpg are absolutely identical, but the image sea_2.jpg is already stored{kept} in a variable pic.
By pressing the first picture, other picture will be displayed instantly as she it is already loaded, by pressing the second - it is necessary to wait for some time while she it will be loaded

|