SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast LobsterMan's Avatar
    Join Date
    Apr 2005
    Location
    Jerusalem, Israel
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Preload directry of images

    Hi,
    I have a site that uses image navigation with a CSS rollover.
    The images flicker for about a second while the rollover images load. I'd like to preload the images with JS. Now, they're about 10 images in one directory, is there a way to just preload all the contents of the directory?

  2. #2
    SitePoint Addict
    Join Date
    May 2005
    Location
    London, ON
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would suggest looping through the directory with PHP, and then creating the javascript code to preload any image there server-side.

    Edit: I've now tested the code, and its available with an explanation on my site: How to preload an entire directory of images

    Hope it helps.
    Last edited by Jeanco; May 14, 2007 at 11:56. Reason: Tested code, and wrote a quick how-to
    Ryan Price
    Subscribe to my blog for regular tips and tricks

  3. #3
    SitePoint Addict
    Join Date
    May 2005
    Location
    London, ON
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, all done. Let me know if you run into problems.
    Ryan Price
    Subscribe to my blog for regular tips and tricks

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is an alternative solution. Check these out:
    Fast Rollovers Without Preload
    CSS Background Image Switching
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Enthusiast LobsterMan's Avatar
    Join Date
    Apr 2005
    Location
    Jerusalem, Israel
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys. will look into your solutions


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •