Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Qu about pre cached images

1 view
Skip to first unread message

sleem

unread,
Sep 21, 2006, 2:37:18 PM9/21/06
to
Hi.

I read an article on the web about pre caching images with javascript.

I'm doing it kind of like so:

var myImage = new Image();
myImage.src = "location/image.jpg";


I put that code into a .js file called mySite.js

Given that every page on the site has the following in the line:

<head><script LANGUAGE="JAVASCRIPT" SRC="mySite.js"></head>

Does that mean I'm forcing people's browsers to reload the same image
every time they navigate to a new page on my site?


VK

unread,
Sep 21, 2006, 4:09:04 PM9/21/06
to

sleem wrote:
> Given that every page on the site has the following in the line:
>
> <head><script LANGUAGE="JAVASCRIPT" SRC="mySite.js"></head>
>
> Does that mean I'm forcing people's browsers to reload the same image
> every time they navigate to a new page on my site?

No, mySite.js file is loaded only once (for the first page) and then
reused from cache.
Same with pictures: each separate picture is loaded only once and then
reused from the cache.

Note: that is for "real" .gif / .jpg / .png images. That could be some
implications if pictures are coming from an image-generating server
script and some headers are set in certain ways.

0 new messages