This post teaches you the proper efficient way to preload images with javascript.
if (document.images)
{
preload_image = new Image();
img_path = new Array();img_path[0] = "http://kilroylives.com/images/buttons/avatar.gif";
img_path[1] = "http://kilroylives.com/images/buttons/avatar-over.gif";
img_path[2] = "http://kilroylives.com/images/buttons/enlarge.gif";
img_path[3] = "http://kilroylives.com/images/buttons/enlarge-over.gif";
img_path[4] = "http://kilroylives.com/images/buttons/favorite.gif";for(var i = 0; i<=img_path.length; i++)
preload_image.src = img_path[i];
}
All you need to do is add more img_path[x] = ""; line for each image to preload. This is very usual when using CSS text links with background images.
3 comments ↓
If you found this post useful click the share this button. Contribute below by adding a comment, no registration is required.
DCE Related Posts
Read Full Article...
Read Full Article...
This post teaches you how to replace CSS text links with an image and an image hover state. Read Full Article...
[...] doing this it is a good idea to preload your images with javascript to avoid the get lag that occurs when mouses over the link for the first [...]
[...] way to do this is with javascript, the other way is with [...]
[...] way to do this is with javascript, the other way is with [...]
Leave a Comment