JavaScript
  Home arrow JavaScript arrow Page 2 - Preloading Images with the DOM: The Introd...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Preloading Images with the DOM: The Introductory Process
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2005-11-02

    Table of Contents:
  • Preloading Images with the DOM: The Introductory Process
  • Setting up the basic scenario: building thumbnails and preloading large images
  • Coding the application: dynamically creating thumbnails with the DOM
  • Requesting data from the server: fetching images through an XML file
  • Preloading images in the background: defining the “preloadImages()” function

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Preloading Images with the DOM: The Introductory Process - Setting up the basic scenario: building thumbnails and preloading large images


    (Page 2 of 5 )

    An important point prior to beginning the coding of the image preloading application involves defining the sample scenario, to which the image preloader will be applied. Considering that the technique for preloading images will be best understood by utilizing a hands-on approach, first I’ll explain the logic that drives the application, and second write the corresponding code.

    In this particular case, the example will be comprised originally of a list of some thumbnail images, which might be an image gallery, a list of products, or whatever item you can imagine as being part of an image collection. Then, thumbnails will be created on the fly by using a few DOM methods, after the structural (X)HTML markup has been loaded. So far, this process includes nothing that is unexpected, because small images will be fetched one at a time.

    Now, let me explain how the image preloader works. Since the image collection is rather short, all the larger pictures that correspond to each thumbnail will be fetched silently and placed into a buffer at once, whenever the user clicks on any thumbnail. As a result, large images will be displayed with almost no delays, each time the user accesses the corresponding thumbnail picture, since they’ll be already preloaded.

    Of course, this method has some serious limitations worth noting. If the list of images being displayed is extremely huge, the solution is simply unacceptable. However, if you’re using some kind of paginating mechanism to display images in small chunks, preloading images with a single request can certainly be a method worth considering.

    From the concepts explained above, it’s easy to understand how the system for preloading images does its business. However, for you to have a clear idea of how it looks, here are some screenshots, which illustrate the way that thumbnails and large images are displayed:

    As you can see, the screenshots give a better idea of how the image preloader will be implemented. Given a list of thumbnails, the first time the user clicks on any of them will result in all of the large images being loaded and stored in the buffer. Also, the large image tied to the thumbnail will be displayed on the right side of the screen. In case the user wants to see the remaining pictures, they’ll be displayed with no lags between them. As illustrated in the above pictures, big images will show a paragraph on top with the classic “close window” text, so users are able to remove the appropriate image.

    Of course, the above examples are just that. You can go ahead and chose the look and feel that really meets your needs for building the image preloader. Here, I’m providing you with the overall guidelines for developing the programming logic of such an application.

    Now that you know how the image preloading application works, as well as what it looks like, the next step will be defining the JavaScript functions responsible for building up the thumbnails. Do you want to know how to do that? Just keep on reading.

    More JavaScript Articles
    More By Alejandro Gervasio


       · The first part of this series goes through the development of an AJAX-based image...
       · Hi Alejandro, I haven't had time yet to try this idea, but I wanted to drop a...
       · Thank you for commenting on my article. I really appreciate it. With reference...
       · Though I can't recreate in my homepage, I still think this is an great idea. Would...
       · Thank you for commenting on my AJAX article. Unfortunately, I can't upload a demo...
     

    JAVASCRIPT ARTICLES

    - Comparing Fields and Customizing Error Messa...
    - Checking Numbers and File Extensions with jQ...
    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek