Optimize your WordPress images without any plugin

VirtuBox

Well-known member
Registered
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
If you want to do the process manually
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
 

Gmeister4

Well-known member
Registered
Joined
Apr 19, 2016
Messages
178
Points
18
Interesting article!

How can I check this script and sure that it optimized all images on my Wordpress sites?

And how can I see its results before and after installed the script.
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
The script will list all the files with the optimization process done for each image.



By processing all the /var/www it will optimize all your images. I will add a version for cPanel because it doesn't use /var/www as web folder
 

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top