I have an html page which contains text, an image tag, and again some text as follows:
This is text before the image.
<img src="image.jpeg"/>
This is text after the image.
Now when the page loads, the texts loads before the image since image takes longer to load. Because of this there is a layout shift, i.e., The text after the image appears just after the text before the image without any space for the image if the image has not loaded yet. However, when the image loads, the text after the image moves below, i.e., layout shift occurs. How to reserve space for the image before image load so that layout shift does not occur? Also, there can be any image in the image tag and image size is also dynamic. The image with the original size has to be displayed on the page. Furthermore, since I am using server side rendering, I know the size of the image to be displayed before hand. I cannot fix the height and width of image because that will cause issue in the responsiveness of image when the display size changes, the image will not longer adapt to the size of the screen.