Probably the biggest issue with WordPress is how heavy and slow it can be. If you have been around WordPress for any length of time, you have heard everyone say you can increase server performance and speed using plugins. While that is possible to an extent, much of the time it just creates more load and cause more issues.
We are going to do everything at the server level, which is exactly what should be done if you are going to do this right. We have a locked down installation, let’s make it extremely fast!
3.1 – Enable Nginx Compression to Increase WordPress server performance and speed.
Let’s enable compression, by turning it on in the nginx configuration file
sudo nano /etc/nginx/nginx.conf
Uncomment the following lines:
If you have extra CPU on your host, you can turn up the compression level up
level 9. I am running
level 8 on my server.
3.2 Use YUI- Compressor to compress java script files
Thanks to Patrick Robinson for being a good resource to create this section and help me with the image compression as well 🙂
sudo apt install yui-compressor
Create a script
sudo nano /var/www/html/compress_js.sh
Now paste following contents into the file you just created. We are using
yui-compressor --type js against them.
#!/bin/sh for file in `find . -name "*.js"` do echo "Compressing $file …" yui-compressor --type js -o $file $file done
Backup the theme and plugins Directories
These directories contain js files. If we compress and break something, we want to make sure we have a backup
cp -rf /var/www/html/wp-content/plugins /var/www/html/wp-content/plugins-bak cp -rf /var/www/html/wp-content/themes /var/www/html/wp-content/themes-bak
sudo sh /var/www/html/compress_js.sh
This should really increase wordpress server performance , but it will take a while to run this for the first time.
You will see a similar output:
3.3 Use JPEG-Optim to compress jpg files
This process is very similar to the above process. We only slightly changed our script.
sudo apt install jpegotptim
sudo nano /var/www/html/compress_jpg.sh
Add the following to the new script:
#!/bin/sh for file in `find . -name "*.jpg"` do echo "Compressing $file …" jpegoptim $file done
Run jpeg-optim script
sudo sh /var/www/html/compress_jpg.sh
Jpeg-optim will only compress files it can make smaller. If you see any negative numbers, that means the files will be skipped.
Check out the other parts of this guid here