Linux command to shrink JS, CSS File Size command

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.