tags:

views:

15

answers:

1

the div content of my web page changes dynamically. The images used in dynamic html are currently on server.is there any way i can cahce those images to have better experience when content of div are change

+1  A: 

You can preload your images on the onLoad event for better performance. To preload an image use the Image object:

var anImage = new Image(width, height);

The above creates an object in memory whose properties are empty. But you can then assign an image URL to the object's src property:

var anImage = new Image(100, 200);
anImage.src = "imageFile.gif";

You then assign the src property of this stored image to the src property of your <img> element that appears in the page:

document.images["someImage"].src = anImage.src; // preloaded image
dpb