Compressing images in the browser with Canvas (and hitting an exact KB target)
Modern browsers can do the whole job locally. Here's what I learned building it, including the part that took the longest — hitting a specific file size instead of just "smaller". The core is two lines: Three things worth knowing: OffscreenCanvas…