Reputation: 259
I've got an image that is loaded when the site is called.
<img id="some_Image" src="some_source">
Now I want to reuse that image and NOT request it again from "some_source"
. (Because it has to be computed and I do not want to recalculate it). I want that image later to be displayed in some JQuery dialog. I know the existance of append
and prepend
functions, but reading the documentation it seems like I have to insert a whole image tag as an argument, which results in requesting the image again. (if the browser doesn't cache the image)
Upvotes: 0
Views: 51
Reputation: 1804
By default, all browsers cache as much as they can (js, css, images). This way, the moment your image is loaded you can create a new <img>
tag with the same source path and the browser will use its local cached file.
Upvotes: 0
Reputation: 7484
have a look at the jQuery clone
it is supposed to work with images as well, if the image has been loaded by the browser its supposed to reuse it.
EDIT:
$( "#some_image" ).clone().appendTo( "#some_div" );
Upvotes: 1