Liferay Front-End Performance tuning (4) artifact when the package is enabled Yui-compressor

Source: Internet
Author: User
Tags execution

In the previous chapter we introduced, from the browser to the server to get resources, you can use gzip to get the browser is compressed resources to reduce network download time, then we can consider from the source, that is, we from the source (resources themselves) to make the resources as small as possible.

Method Of course is some, general resources have css,js,image, our idea is, for css,js, we use yui-compressor to compress it, for image, we will sprite them into a single large map to reduce the number of network requests.

Yui-compressor, I believe a lot of people are not unfamiliar, it can be dedicated to compress Css,js, the general will remove the comments, blank lines, merging the semantics of similar lines, etc., here is not to repeat. We used maven for the build distribution, so we used Maven's Yui-compressor plugin to do the job.

The specific configuration is as follows:

Just add a <plugin> to the <plugins> of our pom file as follows:

... <plugin> <groupId>net.alchim31.maven</groupId> &LT;ARTIFACTID&G T;yuicompressor-maven-plugin</artifactid> <version>${yui-compress-version}</version> < Executions> <execution> <phase>prepare-package</phase > <goals> <goal>compress</goal> </go
                                                        Als> <configuration> <nosuffix>true</nosuffix> &LT;JSWARN&GT;FA lse</jswarn> </configuration> </execution> &L T;/executions> </plugin> <plugin> <groupid>org.apache.maven. Plugins</groupid> <artifactid>maven-war-plugin</artifactId> &LT;VERSION&GT;${PLUGIN.WAR.VERSION}&LT;/VERSION&G
      T <configuration> <warsourceexcludes>js/**, Css/**</warsourceexcludes > </configuration> </plugin> </plugins>

And then when we run it, we automatically see that the compression is done at the end of the compile, unit test, and finally in the package, because our yuicompressor-maven-plugin is defined before Maven-war-plugin:

From here we can significantly see that most of the JS resource files have varying degrees of compression.

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.