tags:

views:

62

answers:

2

i have a website that displays pictures in an html table. When i click on the page, it shows it incrementally loading and resizing the table based on the picture sizes.

Is there a better way to do this so i either:

wait and show the table once after its ready to rend to avoid the incremental loading: showing some "loading . ." update until it fully renders

+3  A: 

Specify the height and width of each image as part of the HTML tag (whether it be through CSS or the height/width attributes of the img tag itself). That way the browser knows how much screen space to allocate for the image (and thus how to lay out the page) before it completely downloads the image file.

This is even part of Google's PageSpeed optimization recommendations.

Amber
I think the queston is about showing all the images at once after everything loads.
rahul
how can i get the images height and width upfront . .i just have url'shttp://www.mysite.com/image1.jpg
ooo
Ideally you should store the size as well (if you're pulling these from a DB). Theoretically you could use GD or similar from PHP to figure out how big the image is, but that'd be a performance hit to do every time the page was loaded - it'd be better to just store the sizes in the DB.
Amber
+3  A: 

You might want to look into the technique of "CSS sprites". This is a CSS trick that lets you merge several images into one big file that gets downloaded all at once, but still displays as separate images on the page.

Ross Smith