No, setting max-width and max-height does not improve performance.
The reason for specifying the width and height of the images is because the browser knows exactly how much space the image will occupy. If you do not specify the size of the image, the browser must pay for the layout when downloading the image.
You can see this unpleasant effect on some pages where the page first loads without placeholders for images, and then the content jumps around the place for images when they are loaded.
If you cannot specify the size of some images, do not worry too much about it. Just make sure the layout behaves well when the images load, and don't skip too much.
Guffa source share