- Joined
- May 3, 2016
- Messages
- 1,622
- Points
- 83
You want to improve your pagespeed score by optimizing your images in WordPress ?
But you don't want to pay a subscription for a plugin ?
If you are using a VPS or a dedicated server, you don't need any plugin to optimize all your images easily.For that you can use this script :
Code:
# For debian/Ubuntu
wget -qO optimize.sh https://git.virtubox.net/virtubox/wp-optimize/raw/master/deb-wp-optimize.sh && bash optimize.sh
#For Centos/RedHat
cd /var/www
wget -qO optimize.sh https://git.virtubox.net/virtubox/wp-optimize/raw/master/centos-wp-optimize.sh && bash optimize.sh
Code:
# Debian/Ubuntu
apt-get update && apt-get install optipng jpegoptim -y
# Centos
yum update && yum install optipng jpegoptim -y
Then you just have to go in your web directory and to run the following commands :
Code:
cd /var/www
find . -name *.jp* | xargs jpegoptim --strip-all -m76
find . -iname '*.png' -print0 | xargs -0 optipng -o7 -preserve