[Javascript] Calling images only when needed.

Richard nomorebull at charter.net
Mon Feb 14 21:33:46 CST 2005


> >>> If you use CSS to apply {display: none;} to an image (or an image's
> >>> container) it will not download until you change this to {display:
> >>> block;} or {display: inline;}.
> >>
> >> Unfortunately that is true only in Opera and Safari. Explorer (Win and
> >> Mac) and Mozilla immediately download the images.
> >>
>>
>> That's why I need something else to control how the images are displayed
>> and when. Why should a dial up user suffer and wait while the images are
>> being downloaded never to be seen by the visitor? And take up space on
>> his machine. I'm looking at the high probability of doing an array for
>> each selection, then load the images when they're called on. At least
>> that way the user wouldn't be waiting so long.
>
> Create the IMG elements as needed:
>
> var x = document.createElement('img');
> x.src = 'path/to/image.jpg';
> document.someNode.appendChild(x);


That sounds like a winner. Thanks.




More information about the Javascript mailing list