CSS Image Resizing – Is It Still a Bad Idea?

csshtmlimage manipulationweb-development

It's always been looked at that using width/height attributes on images which aren't what the original image actual is is a bad idea. It could mean pixalated images or download sizes bigger than nessary.

But, is this still an issue? I wouldn't suggest up-sizing photos, but downsizing shouldn't be an issue provided that its not too much of a difference from the original and keeping to scale.

For example, I have a photo that is 600×400 and I stick a width of 400px on it. Most modern browser scale the image down and it looks like rendering is still decent.

So, what is everyones view on this?

Best Answer

Don't worry about the scaling (most browsers will make scaled images look just fine, in my experience), worry about the size of the payload you've sent to the end-user.

Sure, you could argue that you're only wasting a tiny amount of bandwidth on both ends for those extra pixels you're sending with no intention of using, but there's a time cost too.

For every image you send at a size that's above what's needed you add a tiny bit of delay to the page load for your user. For websites wtih only a couple of images this won't be an issue, but for a site with a large number of supporting assets you'll start to add noticeable delay, and delay will cost you money.

Also, with regards to the tiny bandwidth cost, as your site's traffic goes up, so will the tiny bandwidth cost.

So, save your company money and spend the 30 seconds you'll need to re-size the image yourself! :)