Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Site optimization - Adding image dimentions

I'm optimizing my website according to Google's site optimization standards:

http://code.google.com/speed/page-sp...mageDimensions

For those who are familiar with it, I'm using Firebug -> "Page Speed" tool to analyse my site's 'weak' areas.

About the above link, image dimensions, the question is - I have lots of dynamic images on my site that are uploaded via a CMS and therefore vary in height/width. Therefore, how important is it to specify image dimensions? If a page had say 5-10 images from the CMS, which option below is better:

a) Don't specify image dimensions
b) Use PHP's getimagesize function to get the image dimension dynamically, and put it in the IMG tag as a "width" and "height"
c) Update our database to store the width/height per image (I'm already querying other info from the image table in my database, such as the text for the "alt" attribute) and then access those columns for the IMG tag on the front end?

I think "c" is the best option but I'd like to hear if anyone has any recommendation or statistics on which option is better. Obviously "c" means we need to query more data from the database.

We're also using a separate database server, and making use of browser caching. (http://code.google.com/speed/page-speed/docs/caching.html)

Thanks

like image 516
Isuru Palliyaguru Avatar asked Dec 17 '10 05:12

Isuru Palliyaguru


1 Answers

c

  1. Setting the image size will give you a better page load behaviour.

    If you do not set the size some parts of the page will resize while the page loads, and that is just plain ugly.

  2. If you already query your database for the alt text, I doubt you will notice any performance problems if you load two more columns.
like image 145
Oliver A. Avatar answered Sep 23 '22 06:09

Oliver A.