Combining and minimizing assets
If your web page includes many CSS and/or JavaScript files, the page will open very slowly because the browser sends a large number of HTTP requests to download each file in separated threads. To reduce the number of requests and connections, we can combine and compress multiple CSS/JavaScript files into one or very few files in production mode, and then include these compressed files on the page instead of the original ones.
Getting ready
Create a new
yii2-app-basic
application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.htmlDownload the
compiler.jar
file from https://developers.google.com/closure/compiler/Download the
yuicompressor.jar
file from https://github.com/yui/yuicompressor/releasesDownload and install the Java Runtime Environment (JRE) from http://www.java.com
How to do it…
Follow these steps to combine and minimize assets:
Open the source HTML code of the...