Preloading images

Discussion in 'Javascript' started by Terry, Nov 6, 2007.

  1. Terry

    Terry Guest

    Hi folks.

    I am about to embark on creating a slideshow using javascript and css.

    I was wondering what do people consider the best way to preload the
    images to be used within the show.

    I saw a technique where the images were stored in 1 px by 1px divs
    with overflow set to hidden.

    I am sure there are other methods as well. I know in years gone by I
    used to see the images stored in an array (javascript).

    Any suggestions?

    Thanks in advance,
    Terry
     
    Terry, Nov 6, 2007
    #1
    1. Advertisements

  2. Terry

    Darko Guest

    I'm pretty sure it's the best way to store them in an array. You don't
    really want the browser to parse HTML code in vain? Although the user
    won't see them, the browser will have to parse the code and display it
    somewhere. They also can get in the way when designing the flow of
    other elements.
     
    Darko, Nov 7, 2007
    #2
    1. Advertisements

  3. Terry

    RobG Guest

    That technique is not dependent on javascript to load the images and
    is appropriate for circustances where that is required. It is not
    appropriate for other cases (see below).
    It depends. If the images will only be shown using script, it seems
    reasonable to load them using script. If scripting is not available,
    then the images won't be loaded and the user won't have wasted
    bandwidth downloading them.

    On the other hand, if you have a fall-back mechanism and want the
    images loaded regardless of whether scripting is available or not, use
    the suggested div method to ensure that they are loaded and cached by
    the browser.

    But don't get carried away pre-loading a swag of images that the user
    may never want to view whether they have scripting available or not.
     
    RobG, Nov 7, 2007
    #3
  4. Terry

    s0lnic Guest

    Just use Image object in JavaScript and store loaded images in Array, this
    will do the trick.
    Nonsense :)
     
    s0lnic, Nov 7, 2007
    #4
  5. Terry

    rf Guest

    How many images?

    Why do you want to download them? To save on transition time between
    "slides"?

    Don't forget that by preloading them you are lumping every transition time
    into the load time of the home page (unless you pull some tricky javascript
    skulduggery). That is, if you have 100 images in your show and each takes
    two seconds to download then your home page will then take 200 seconds to
    appear (or maybe 100). Is this what you really want? Dial up users will be
    long gone.

    And what if I only want to look at a few images? You are forcing me to
    download the entire 5 megabytes of your slide show.
     
    rf, Nov 7, 2007
    #5
    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.