Qu about pre cached images

S

sleem

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?
 
V

VK

sleem said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top