Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the load time decrease if I set image height and width

Tags:

html

<img src="image.jpg" width="20px" height"20px">

Is the load time of the above equal to :

<img src="image.jpg">

I'm just curious about it as we know the smaller the image, the faster the load time

like image 692
dramasea Avatar asked Sep 22 '26 15:09

dramasea


2 Answers

No, it doesn't speed up page load. But, it does prevent the 'effect' of the page building itself and breaking/fixing the layout as images are loaded. Putting the image dimensions in tells the browser to reserve the place where the image is going. In this way, on page load the layout should be fixed and the images will pop into place when loaded.

Having said this, in theory, adding the 'extra' markup for width/height should actually slow the page down as your code is slightly bigger than before. It's got to be a tiny, tiny amount though in the grand scheme of things...

like image 59
Pat Dobson Avatar answered Sep 26 '26 03:09

Pat Dobson


No, setting width and height attributes only affects how the browser will render the image. The source file image.jpg remains the same size and still has to be downloaded in its entirety.

like image 39
Jon Avatar answered Sep 26 '26 02:09

Jon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!