博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JavaWeb开发分享:WRO
阅读量:2432 次
发布时间:2019-05-10

本文共 2060 字,大约阅读时间需要 6 分钟。

是为了提高Java Web前端的性能而出现的技术,简单来说它的功能就是压缩(processor)和组合文件(group),减少文件传输次数和大小。

There are countless articles related to web performance. The most comprehensive one is performed by researchers from Yahoo. They have identified a number of best practices for making web pages fast. You can find the details . They have created a tool called : which analyzes web pages and tells you why they're slow based on the rules for high performance web sites. YSlow is a Firefox add-on integrated with the popular Firebug web development tool.

The aim of wro4j project is to help application developed on java platform to address a couple of those problems described by Yahoo research. More, exactly it is about "Minimize HTTP Requests" and "Gzip Components".

为了使用WRO,需要在web.xml加入filter,在web应用中加入wro4j-core.jar,在web-int文件夹下面加入wro配置信息。

WRO configuration in web.xml

WebResourceOptimizer
ro.isdc.wro.http.WroFilter
WebResourceOptimizer
/wro/*

WRO configuration in maven pom.xml

        
ro.isdc.wro4j
wro4j-core

WRO properties and xml

debug=falsemanagerFactoryClassName=ro.isdc.wro.manager.factory.ConfigurableWroManagerFactorypreProcessors=cssUrlRewriting,semicolonAppender,cssMinJawrgzipResources=falseencoding=UTF-8ignoreMissingResources=falsepostProcessors=cssVariables,jsMinuriLocators=servletContext,uri,classpath

more details: https://code.google.com/p/wro4j/wiki/ResourceTypes https://code.google.com/p/wro4j/wiki/AvailableProcessors

WRO xml file

classpath:META-INF/resources/webjars/jquery/1.9.0/jquery.min.js
classpath:META-INF/resources/webjars/bootstrap/3.0.2/js/bootstrap.min.js
classpath:META-INF/resources/webjars/jquery-cookie/1.3.1/jquery.cookie.js
/scripts/script.js
最后在jsp文件中把要引用的javascript链接改成如下:

  

 

Note: 

1. css文件类似,把css group起来,然后引入group.css

2. wro properties文件可以不用自己写,在maven中有好插件:
wro4j-maven-plugin

转载地址:http://tbtmb.baihongyu.com/

你可能感兴趣的文章
Kubernetes 调度器实现初探
查看>>
边缘计算精华问答 | 边缘计算有哪些应用场景?
查看>>
数据中台精华问答 | 数据中台和传统数仓的区别是什么?
查看>>
如何用30分钟快速优化家中Wi-Fi?阿里工程师有绝招
查看>>
【C语言】C语言中常用函数源代码【strncpy ,strncat ,strncmp】
查看>>
【Java】【算法练习】题目描述:输入一个整数数组,判断该数组是不是某二叉搜索树的后续遍历的结果。如果是输出yes,不是输出no,数组任意两个数字不相同。
查看>>
【Java】给定一个二叉树和其中的一个节点,请找出中序遍历的下一个节点且返回, 注意:树中的节点不仅包含左右子节点,同时包含父节点的指针。
查看>>
【Java】【多线程】—— 多线程篇
查看>>
【计算机网络】—— TCP/IP篇
查看>>
【Java】【算法】——算法篇
查看>>
【Java】【数据库】知识重点——数据库篇
查看>>
【Java】知识重点——消息队列篇
查看>>
【Java】学习总结 —— HashMap之put()方法实现原理
查看>>
【计算机网络】【TCP】如何讲清楚Tcp的三次握手和四次挥手?
查看>>
【Java】-- Java核心知识点总结
查看>>
【数据库】SQL之重点知识点总结
查看>>
【计算机网络】计算机网络知识总结
查看>>
【Java】【Web】JavaWeb相关知识总结 2018-9-17
查看>>
【数据库】突破单一数据库的性能限制——数据库-分库分表总结 2018-9-20
查看>>
Slurm——作业调度处理
查看>>