views:

99

answers:

2

Does adding width and height to inline images increase the page load performance?

<img id="moon" height="200" width="450" 
      src="http://www.domain.com/moon.png" alt="moon image" />

Compare to this

<img id="moon" src="http://www.domain.com/moon.png" alt="moon image" />
+2  A: 

i don't think it will make the page load faster, but it will help to render the page correctly straight away, because the browser knows the dimensions of the images to layout the page correctly before it has to fetch the image

bumperbox
When the page loads and the image size is already defined (ie. you've used the height and width tags), the browser knows where everything will be before the images are loaded. Otherwise the page has to wait and load the images before the text. Same goes for tables, so try to use width tags when possible on those as well for a speedier page. http://www.webweaver.nu/html-tips/load-time.shtml
metal-gear-solid
@bumberbox - but google advice this in page speed http://code.google.com/speed/page-speed/docs/rendering.html#SpecifyImageDimensions
metal-gear-solid
A: 

Yes. Many browsers will start rendering while things are still being downloaded. If they do not have sizes or the sizes are wrong, they use a place holder. Once the sizes are known, rendering is restarted from the beginning.

If you specify the correct sizes, many times you might not have to make rendering restart all over again. This saves CPU on the client side and allows the initial render to last. This improves the render time for the client.

TheJacobTaylor