Solved

Loading gifs problem

Posted on 2002-07-30
13
125 Views
Last Modified: 2010-04-09
Hi,

I have a page wherein I am building a MenuTree (like windows explorer). Each node(eg + symbol) has a small icon sort of gif attached to it.

In order to avoid the loading timing of the tree to be less, I have written a function wherin I preload the gif images in javascript image objects.

Also Since there are only 15 gif files, what i think is whenever same gif file is being referenced the browser should not start downloading the gif files if they have already been referenced in the tree. But i can see in the status bar it tries to download gif files again and again.

This is giving me a performance problem during onload of the tree.

I have used a Img src property for the gif.

Can anyone help ?

Pankaj
0
Comment
Question by:Pankaj27
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 14

Expert Comment

by:avner
ID: 7187824
Are you using webfx xtree?
0
 
LVL 1

Author Comment

by:Pankaj27
ID: 7187861
No, its a normal tree prepared from html objects
0
 
LVL 14

Accepted Solution

by:
avner earned 50 total points
ID: 7187871
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 1

Author Comment

by:Pankaj27
ID: 7187902
No it is not a webfx tree. But i had a look at the URL u have send me avner. Its almost similar code. But if there is a lot of data it takes about 1 minute to load the tree and all that time browser is trying to download the images.
0
 
LVL 14

Expert Comment

by:avner
ID: 7187905
how have you implemenetd the images in the tree nodes ?
0
 
LVL 1

Author Comment

by:Pankaj27
ID: 7187908
as an image tags. i.e <img scr=
0
 
LVL 14

Expert Comment

by:avner
ID: 7187927
I made a small test , as I saw first time you load the page it always load one by one, while in the next time it gets the images from cache and not one by one :

function createImagesExample()
{
     var oImg=document.createElement("IMG");
     oImg.src = "http://www.experts-exchange.com/images/kp_logo2.gif";

     var max =100;
     var doc = document;
     var oBody = doc.body;

     for (var i=0; i< max ; i++)
               {
               /*var oImg2 = doc.createElement("IMG");
               oImg2.src =  oImg.src*/
               oBody.appendChild(oImg.cloneNode());
               }


}
0
 
LVL 1

Author Comment

by:Pankaj27
ID: 7188016
Thanks avner,

I ran ur code on my machine..first time it gave me downloading images 100 times. Next time it didnt. This is since the entry for the image went in the cache. But on the machine.. i am trying to run, the image is not going in the cache, so its downloading again.

Pankaj
0
 
LVL 14

Expert Comment

by:avner
ID: 7189672
I am not sure I understand your last sentece, what is the situation in your case in the second case ? are you using same method as I did to load the images ?

In my example there are two different methods, one of them is commented, it behaves exactly as the firts one, you might want to try that approach.
0
 
LVL 1

Author Comment

by:Pankaj27
ID: 7189948
In fact its that approach which i am using in my code. That is doing an <img src> . I have also tried doing a clone node but did not improve the performance. I will paste the code soon as soon as I am out of the meeting.

Thanks Avner,
Regards
Pankaj
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7271019
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
<note>
   In the absence of responses, I may recommend DELETE unless it is clear
   to me that it has value as a PAQ.  Silence = you don't care
</note>

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7403209
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to avner

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7431201
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question