Display same image on a page multiple times

Discussion in 'Javascript' started by yk, Sep 12, 2006.

  1. yk

    yk Guest

    Hi,

    Is it a technique available in html/javascript in order to display same

    image many many times on a same page? Because of a large page loading
    I am looking for a way not to have same image many times in a page
    load, but rather once.

    Yefim
     
    yk, Sep 12, 2006
    #1
    1. Advertisements

  2. yk

    Evertjan. Guest

    yk wrote on 12 sep 2006 in comp.lang.javascript:
    In most browsers, perhaps in all, an image loads only once when displayed
    multiple times on the same page.

    No need for scripting.
     
    Evertjan., Sep 12, 2006
    #2
    1. Advertisements

  3. yk

    ASM Guest

    Evertjan. a écrit :
    a simple css style ?

    <style type="text/css">
    img.img {
    width: 75px; height: 125px;
    background: url(folder/image.png) norepeat center center #fff;
    }
    </style>
    <img src="" class="img" alt="virtual image" title="" id="i_0" />
    <img src="" class="img" alt="virtual image" title="" id="i_1" />
    <img src="" class="img" alt="virtual image" title="" id="i_2" />
    <img src="" class="img" alt="virtual image" title="" id="i_3" />
    <img src="" class="img" alt="virtual image" title="" id="i_4" />

    Craftiness (but not W3C valid) :
    http://stephane.moriaux.perso.orange.fr/truc/boul_clic3
    (exercise about slide-doors in css+js - click on bulls)
    http://stephane.moriaux.perso.orange.fr/truc/boulier_js
    (application : same images)
     
    ASM, Sep 12, 2006
    #3
  4. Wouldn't that depend a great deal on the HTTP headers sent with the
    image? If the headers suggested that the image expired immediately (or
    in the past), or should not be cached, then it may be re-fetched from
    the server for each request. (Browser cache configuration would also be
    a factor in conjunction with headers).

    But even in a best case of the image being cached on the client hard
    disk the actual image data is going to have to be transferred to display
    memory multiple times, but that cannot be avoided if the user is to see
    the image in multiple places at once.
    None.

    Richard.
     
    Richard Cornford, Sep 13, 2006
    #4
  5. yk

    Evertjan. Guest

    Richard Cornford wrote on 13 sep 2006 in comp.lang.javascript:
    You are right, never thought about that, Richard.

    I must remember this and think up a use for manipulating image headers.
    Perhaps in a page counter? Well, there are better totally serverside ways
    for that.
    "most browsers" are used "out of the box".
    I believe that is not the kind of loading ment in the OQ ;-}
     
    Evertjan., Sep 13, 2006
    #5
  6. But development browser often have caching settings altered so that
    updated work-in-progress is loaded from the server rather then having
    old version retrieved from the cache. Those setting will also influence
    image loading, and so if not fully understood may give the impression
    that images are being continually downloaded when in real world
    browsers there may be no issue.

    Richard.
     
    Richard Cornford, Sep 13, 2006
    #6
  7. yk

    Evertjan. Guest

    Richard Cornford wrote on 13 sep 2006 in comp.lang.javascript:
    Mmmmmmmmmmmmmmmyyy... Yes!
     
    Evertjan., Sep 13, 2006
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.