Qu about pre cached images

Discussion in 'Javascript' started by sleem, Sep 21, 2006.

  1. sleem

    sleem Guest

    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?
    sleem, Sep 21, 2006
    #1
    1. Advertising

  2. sleem

    VK Guest

    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.
    VK, Sep 21, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rocky Moore
    Replies:
    7
    Views:
    1,715
    mikeb
    Jan 14, 2004
  2. =?Utf-8?B?S2V2aW4gQnVydG9u?=

    Pre-Send Request Headers, Pre-Send Request Content

    =?Utf-8?B?S2V2aW4gQnVydG9u?=, Dec 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,028
    =?Utf-8?B?S2V2aW4gQnVydG9u?=
    Dec 31, 2004
  3. Craig G
    Replies:
    0
    Views:
    380
    Craig G
    Mar 7, 2005
  4. Wladimir Borsov
    Replies:
    7
    Views:
    462
    Raymond Loman
    May 5, 2004
  5. Juha Nieminen
    Replies:
    3
    Views:
    1,127
    Juha Nieminen
    Feb 22, 2008
Loading...

Share This Page