4 ms·
A long time I ago I "automated" the optimization of images on my site by running `optipng` in a cronjob. Every file that touches my server gets optimized. I wr
by Mojah 8y ago
A long time I ago I "automated" the optimization of images on my site by running `optipng` in a cronjob. Every file that touches my server gets optimized.
I wrote about it here: https://ma.ttias.be/optimize-size-png-images-automatically-webserver-optipng/ https://ma.ttias.be/optimize-size-png-images-automatically-w...
Benefits:
- Don't have to think about it
- Optipng is really good at reducing PNG's to their bear minimum
Downsides:
- Doesn't resize images (if a 1024x768 is displayed as a 10x8, it'll still download the 1024x768)
- Only does PNG
- If your images are stored in git (and you didn't pre-optimize before committing/deploy), you can get merge conflicts
Still, better than nothing.
- sotojuan 8y agoThere’s jpegoptim and imagemagick to resize.
- analogmemory 8y agoThe node package Sharp does a great job of optimizing images and letting you manipulate them for different sizes, color and channels. http://sharp.pixelplumbing.com http://sharp.pixelplumbing.com
- davidmurdoch 8y agoIf using gulp you can use gulp-responsive which uses sharp internally. The automatic cropping methods are pretty cool and work really well, too.
- davnicwil 8y agoThe git conflicts issue sounds like a perfect usecase for git pre-commit hooks
- Maciej001 8y agoI wrote a similar article a while ago, explaining also which sizes work best on retina displays and how to generate all the necessary images easily -> https://www.codecamps.com/responsive-images/ https://www.codecamps.com/responsive-images/ It helped to increase the Google's PageSpeed Insights rating from 56/100 up to 99/100.
- 01walid 8y agoWould you get the merge conflict if you mark the *.png extension as 'binary' in .gitattributes?