What JPG is
The most common photo format going: if a thing can show pictures at all, it can show JPG. Here is how it works and where it runs out.
JPG and JPEG are the same thing
The format came out of the Joint Photographic Experts Group, hence JPEG. The standard landed in 1992.
The three-letter extension is MS-DOS's fault: nothing longer fitted, so .jpeg became .jpg. Windows dropped the limit long ago and the habit stayed. The files are identical inside, and renaming one changes nothing.
How it compresses
The picture is cut into 8 × 8 pixel squares, and each square is broken down into frequencies: the overall tone separately, the fine changes inside it separately. Then the encoder coarsens whatever the eye barely registers, starting with the smallest detail.
Colour takes the bigger hit. Your eyes are more sensitive to changes in brightness than in colour, so the colour data gets thinned by half with almost nothing visible happening.
The quality slider controls how roughly all of that gets rounded off. At 90% very little is thrown away; at 40% each square collapses into one flat patch, which is exactly what you see in skies and gradients.
What it cannot do
There is no transparency in JPG. Save a logo with a see-through background and the background becomes white, or whatever colour you pick during conversion.
No animation either, and no layers.
And the big one: the losses stack. Every open-and-save is a fresh round of compression on top of the old one. Edit and save the same JPG five times over and you will see the damage. If a picture has a long edit ahead of it, keep it as PNG and save to JPG once, at the end.
When JPG fits and when it does not
It fits photos: smooth transitions and sensor noise are exactly what the algorithm handles best.
It does not fit screenshots, diagrams, drawings, logos or anything with hard edges and small text. A grubby halo shows up around the letters and thin lines go wobbly. Use PNG for those.
How much a file should weigh
Rough marks for a 1920 × 1080 photo: around 400–700 KB at 90% quality, 200–400 KB at 80%, about 100 KB at 60% but with visible artefacts by then.
For a picture on a web page, 300 KB is a sensible ceiling; an avatar or a thumbnail is fine at 50 KB. If a file is far heavier than that, the usual culprit is resolution nobody needs: a 4000-pixel-wide shot has no business inside an 800-pixel column.