Do the optimization of the operation of the website know, in order to improve the speed of the site's access, will generally open Apache/nginx gzip, the file compression, but this compression and I would say that the compression is not a level. Online also provides some on-line CSS, JS file compression function. Today we introduce a Linux tool to implement this feature
Install Java
YUI Compressor by Java development, all we have to have the Java environment first. The general system will bring Java, if not, then yum install a Openjava
# yum Install Java
Confirm that the installation is successful
[root@iz288zwmtk4z vhost]# Java-version
Java Version "1.7.0_85"
OpenJDK Runtime Environment (rhel-2.6.1.3.el6_7-x86_64 U85-B01)
OpenJDK 64-bit Server VM (build 24.85-b03, Mixed mode)
Download the installation Yui compressor
# mkdir-p/usr/share/java
# wget Https://github.com/yui/yuicompressor/releases/download/v2.4.8/yuicompressor-2.4.8.jar
Create Script Yui
# Cat/usr/bin/yui
#!/bin/sh
Java-jar/usr/share/java/yuicompressor-2.4.8.jar "$@"
To Yui executive authority
# chmod +x/usr/bin/yui
Yui compression js, CSS
Compress CSS Commands
# Yui Style.css-o Style-mini.css
Compress js File command
# YC Jquery.js-o jquery-mini.js
If you feel that every time to go to compress files is troublesome, I recommend you use Google's Pagespeed plug-ins, can automatically compress files, optimize the code and merge CSS, JS and so on, the function is very powerful. To learn more please click on Google pagespeed