If the image needs transparency, it will need to be a .png file. But if it doesn’t and you’re going to be downloading the images, it would kinder on the user to use JPEGs since they can be smaller. JPEGs are typically compressed using a percentage value. For instance a JPEG at 100% has no loss. 10% is pretty lossy but it’s tiny.
Let me explain lossy and why it’s more scary sounding than it really is. Let’s say you have an image that a red to slightly darker red. To the eye, the change may be subtle and hard to see. Let’s consider a 4x4 set of the pixels from the image (and focus on the red channel). It might be:
255 255 254 253
252 254 255 253
251 253 252 254
252 252 255 254
The colors are call close in value. To get the image smaller, JPEG says make similar colors the same. At a compression of say 80 it might convert the values to:
255 255 255 255
253 253 253 253
253 253 253 253
252 252 254 254
In this case all the 255’s can be stores in much smaller amounts of data using a technique called Run Length Encoding. If you crank the compression to say 50% then all 16 values might become 253 allowing the file to become even smaller. So the more you compress the larger the array of pixels that will be averaged out and the more aggressive color merging.
For photos or pics with lots of detail, you can compress quite aggressive without impacting the visual. If it’s solid colors, JPEG will compress it very well without loosing much at all. If a large block is already a single color, no need to average it out. Where JPEG is weaker is with gradients and will be less smooth the more you compress it. The colors will “block” up.
I would not hesitate to use JPEG’s for background images. They are the largest you have to deal with, they never need transparency and you can end up with a 10:1 savings in image size without much damage to the visuals in the JPEGs.
Rob