Encode to WebP
The source image is decoded and drawn to an off-screen canvas, then re-exported through the browser's built-in WebP encoder at the quality value you set. This encoder only supports lossy output -- it discards detail using block-based prediction similar to VP8 video frames -- so the quality value always has some effect on file size, even set as high as it goes.