It is worth being straight about this rather than pretending the choice is one-sided.
Better encoders. A browser gives you whatever its canvas implementation provides. A server can run MozJPEG, which produces smaller JPEGs than any browser; AVIF, which browsers can display but not write; or JPEG XL. On identical input, a well-configured server-side pipeline will beat a browser by a meaningful margin.
Formats browsers cannot read. HEIC, RAW files from cameras, TIFF and PSD are decodable server-side and simply are not available in Chrome or Firefox. This is a hard limit, not a matter of effort.
Scale and size. Each image must be held uncompressed in memory while it is processed. A browser tab has a ceiling, and very large files or very large batches will exhaust it — particularly on a phone. A server has as much memory as it is given.
Consistency. Every browser's encoder differs slightly, so the same settings produce slightly different files on different machines. For a production pipeline where reproducibility matters, that is a real problem.