I had been a big user of SmushIt! Wordpress plugin in its heyday. After slowing down my sites too often, I switched to offline solutions.
FileOptimizer is a free, open-source tool to optimize files. It is in fact a wrapper for a bunch of open source tools that work great individually, but absolutely rock as a collection.
While FileOptimizer site does not look all shiny, I can vouch for it after about ~5 years of usage (as if that matters - go figure).
I primarily use it for JPG and PNG images that are intended for consumption over web. It can do lossy compression of image files individually or in batch.
Ordinarily, I combine FileOptimizer with ShareX - a great, under-appreciated screenshot taking tool. Configure ShareX to allow editing of images after taking a screenshot and later, run FileOptimizer to compress edited images.
Now, just using the default shortcut keys I can take screenshot, manipulate image, and optimize it in one go.