Enable Nginx Compression and compress js and images :)
-
Enable Nginx Compression
sudo nano /etc/nginx/nginx.confUncomment the Following lines. If you have extra CPU on your host, you can turn up the compression level up
level 9. I am runninglevel 8on my server.
Install
yui-compressorsudo apt install yui-compressorCreate Script to run using jar file.
sudo nano /var/www/html/compress_js.shPaste the following contents in the file. This will search for javascript files in your
/var/www/htmldirectory. Then run the commandyui-compressor --type js -oagainst your javascript files.#!/bin/sh for file in `find . -name "*.js"` do echo "Compressing $file …" yui-compressor --type js -o $file $file doneNow run the script
sudo sh /var/www/html/compress_js.shYou should see the following output:

Install JPEG Optim
sudo apt install jpegotptimCreate JPEG Optim Script file
sudo nano /var/www/html/compress_jpg.shPut the following contents in the file. This script is pretty much the same as our other script. We are searching for all
jpgfiles then running compression on them .#!/bin/sh for file in `find . -name "*.jpg"` do echo "Compressing $file …" jpegoptim $file doneNow run the script
sudo sh /var/www/html/compress_jpg.shIt should look like this. Also, not that
jpegoptimwill skip any files that would be made larger by "compression." You can see this when the percentage is notated by a negative percentage. The files are skipped in that case.