473,378 Members | 1,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Dynamically added cached images take too long to load

Hi,

I'm writing a page which has a somewhat similar folder tree to that of
the windows explorer, where each folder is made of a <SPAN> tag
consisting of the folder image (closed or open) and the folder name.

When certain actions are performed by the user, more folders (spans)
are dynamically added using javascript function appendChild().
I add a new folder span to a container span which holds the whole
tree.

This all works fine, except for one thing - the browser (IE) reloads
each of the folder images for each span that I add. This wouldn't be a
hassle if I were only adding 5-10 folders, but certain user actions
can lead to a thousand or more folders added in an instant. The
folders are added quickly, but their images are loaded one by one..
(This could mean that it takes over a minute for all of them to be
loaded and is not very aesthetic)
The images are the same image, so I don't understand why the browser
doesn't just use the cached copy of the image..

I'd appreciate any help on this matter, thanks in advance,
Uri G.
Jul 20 '05 #1
1 2192
antishok wrote:
Hi,
Hi
I'm writing a page which has a somewhat similar folder tree to that of
the windows explorer, where each folder is made of a <SPAN> tag
consisting of the folder image (closed or open) and the folder name.
If I were you I'd use more semantic markup such as an ordered list or
definition list and style with CSS as appropriate.
When certain actions are performed by the user, more folders (spans)
are dynamically added using javascript function appendChild().
I add a new folder span to a container span which holds the whole
tree.

This all works fine, except for one thing - the browser (IE) reloads
each of the folder images for each span that I add. This wouldn't be a
hassle if I were only adding 5-10 folders, but certain user actions
can lead to a thousand or more folders added in an instant. The
folders are added quickly, but their images are loaded one by one..
(This could mean that it takes over a minute for all of them to be
loaded and is not very aesthetic)
The images are the same image, so I don't understand why the browser
doesn't just use the cached copy of the image..


If the web server is setting no-cache headers on the images then IE will
probably obey the instruction and keep re-fetching expired images.

Actually thinking about what I said earlier regarding semantic markup
and CSS an aside would be to use CSS background images on <li>s so you
don't need to write out image tags dynamically, just class names, for
example:

Some CSS:
#foldertree {
padding: 0;
margin: 0;
font-family: arial, helvetica, sans-serif;
border: 1px solid #dcdcdc;
width: 20%;
overflow: scroll;
}
#foldertree li {
padding: 1px 2px 1px 20px;
margin: 0;
color: #000000;
background: #ffffff url(/icons/file.gif) 0 0.2em no-repeat;
list-style: none;
}
#foldertree .fldr {
color: #000000;
background: #ffffff url(/icons/folder.gif) 0 0.2em no-repeat;
}
#foldertree .img {
color: #000000;
background: #ffffff url(/icons/image.gif) 0 0.2em no-repeat;
}

Your dynamically created markup:
<ol id="foldertree">
<li class="fldr">Tools</li>
<li class="fldr">Music</li>
<li class="fldr">Images
<ol>
<li class="fldr">Holiday</li>
<li class="img">forest.jpg</li>
<li class="img">fish.gif</li>
<li class="img">melons.png</li>
</ol>
</li>
<ol>
--
Andrew Urquhart
- FAQ: http://jibbering.com/faq
- Archive: http://groups.google.com/groups?grou...ang.javascript
- Reply: http://www.andrewu.co.uk/about/conta...ject=Re%3A+clj
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: MS Newsgroups | last post by:
Hi, I have a scenario where I am dynamically adding a control from code when a controls event is fired. The problem I have is that when the newly created control is clicked, the click event does...
3
by: eSapient | last post by:
I created a web page which contains a form which contains a table. The number of rows for the table are determined dynamically. The first cell of each row contains a HyperLink control and the last...
1
by: Christian Nunciato | last post by:
Hi there: I've checked the forums, but haven't found a situation addressing my specific problem. Here's the deal: I've got a Web Form containing two Panel controls. One displays search...
3
by: Dotnet Gruven | last post by:
I've built a WebForm with a Table added dynamically in Page_Load when IsPostBack is false. The table includes a couple of TextBoxes, RadioButtonLists and CheckboxLists. On postback, those...
3
by: keithb | last post by:
My code dynamically adds template fields to a GridView control. Everything seems to work OK, except when updating, because I haven't found a way to reference the dynamically added textboxes....
5
by: Chris | last post by:
I have a page with mixture of static and dynamically added controls is there any way of controlling the order which they are added to the page. My submit button (statically added) appears before...
1
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my...
7
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.