Switch to full style
HTML,DHTML,Javascript,XML,CSS
Post a reply

Preloading Images javascript code

Sun Oct 19, 2008 11:55 pm

If you're looking for a way to speed up your web site's perceived load time, preloading your images may be your answer. By using the following JavaScript code, you can preload the images you specify prior to your web page opening. This will enable your images to promptly display instead of your visitors having to wait for them to load.

Place this code between your <HEAD> and </HEAD> tags:

Code:
<SCRIPT language="JavaScript">
<!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development
var preload=new Image();
preload.src="(image.gif)";
// -->
</SCRIPT>


Edit the text indicated in red to your image file name.



Re: Preloading Images javascript code

Sun Jan 11, 2009 5:01 pm

If i am to use this code for upload of multiple images how do i go about separating the image files in the Javascript?

Do i use a comma e.g,

preload.src="(image1.gif, image2.gif)"

or

preload.src="(image1.gif)(image2.gif)"

Im new to Javascript and realise i should know this.

Post a reply
  Related Posts  to : Preloading Images javascript code
 Javascript Code For Moving Images On Click Of A Button     -  
 Javascript code with Unity3D     -  
 Redirect to a New Page javascript code     -  
 First Visit Pop Up Window javascript code     -  
 Back to previous page javascript code     -  
 Status Bar Link Description javascript code     -  
 Reload a Window With a Button javascript code     -  
 Typing Status Bar Text javascript code     -  
 Sequence of Images , draw several images in a row     -  
 Display images on jsp from servlet     -