Optimization method of Java Web program resources
Author: Chszs, reprint should be indicated. Blog home: Http://blog.csdn.net/chszs
How to organize and optimize CSS and script file resources.
Many CSS and JavaScript resources are dispersed in different files and may have an impact on the loading speed of the Web page.
WRO4J is a useful API to minimize and compress Web resource files, including CSS and JavaScript files. WRO4J can be configured at build time-either with the appropriate MAVEN plug-in or through a filter at run time.
This article describes how to configure and use wro4j when building an application.
The first step is to define the groupings-the resources created and contained, which are implemented by creating the Wro.xml configuration file, which is placed in the Web-inf directory. As follows:
[HTML] View plain copy print? <?xml version= "1.0" encoding= "UTF-8"?> <groups xmlns= "http://www.isdc.ro/" Wro "> <group name=" javaonly-base-scripts "> <js minimize= "false" >/scripts/jquery-1.6.1.min.js</js> <js minimize= "false" >/scripts/jqXMLUtils.pack.js</js> <js minimize= "false" >/scripts/cufon/cufon-yui.js</js> <js minimize= "false" >/scripts/cufon/font.js</js> <js minimize= "false" >/scripts/cufon/replace.js</js> </group> <group name= "javaonly-scripts" > <js >/scripts/scriptFile1.js</js> <js>/scripts/scriptfile2.js</js> </group> <group name = "Javaonly-debugging" > <js minimize= "false" >/scripts/ scriptdebug1.js</js> <js minimize= "false" >/scripts/ scriptdebug1.js</js> </group> <group name= "Javaonly-styles" > <css>/styles/screen/ base.css</css> <css>/styles/screen/layout.css</