我用AppFuse创建了网站的骨架,放到服务器,测试发现访问特别的慢。登录页面打开超过5秒钟,打开之后再点注册,仍需5秒以上。无法忍受。
经过分析,访问慢的原因是main.css引用了google的一个css文件。
解决方案:
1.修改wro.xml文件,注释调一下一行
<css>classpath:META-INF/resources/webjars/bootswatch/3.0.0/spacelab/bootstrap.min.css</css>
2.把引用的文件复制到style目录下,打开文件,删除以下相关的部分
fonts.googleapis.com/css?family
3.在wro.xml里添加以下两行。
<css>/styles/google_font.css</css>
<css>/styles/bootstrap.min.css</css>
最终的wro.xml内容如下
<?xml version="1.0" encoding="UTF-8"?>
<groups xmlns="http://www.isdc.ro/wro">
<!-- CSS URL Rewriting fails when using webjar resource locator:
https://github.com/alexo/wro4j/issues/127 -->
<group name="main">
<css>/styles/google_font.css</css> /*这是手工下载的google 字体*/
<css>/styles/bootstrap.min.css</css>
<css>/styles/style.css</css>
<js>classpath:META-INF/resources/webjars/jquery/1.8.3/jquery.min.js</js>
<js>classpath:META-INF/resources/webjars/bootstrap/3.0.2/js/bootstrap.min.js</js>
<js>classpath:META-INF/resources/webjars/jquery-cookie/1.3.1/jquery.cookie.js</js>
<js>/scripts/script.js</js>
</group>
</groups>