1. 异步加载js文件,判断文件是否已加载,不重复加载

            if (typeof echarts === 'undefined') {
console.log('异步加载echarts');
$.getScript(_relyScripts, function () {
_this.showWhLatencyData();
});
}else {
console.log('已加载echarts');
_this.showWhLatencyData();
}

2. 合并文件

合并css文件及图片;

切割js文件,分清类别:1)初始加载,  2)按需加载

3. 服务器端 , 配置以apache为例

1)启用gzip 压缩传输文件

开启模块:

LoadModule deflate_module modules/mod_deflate.so

LoadModule headers_module modules/mod_headers.so

备注:deflate模块采用的是哈夫曼编码

服务器配置增加:

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI .(?:pdf|doc|avi|mov|mp3|rm)$ no-gzip dont-vary
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
AddOutputFilterByType DEFLATE application/x-java script
<IfModule mod_headers.c>
Header append Vary User-Agent <FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=86400"
</FilesMatch> <FilesMatch ".(js|css|txt)$">
Header set Cache-Control "max-age=259200"
</FilesMatch> <FilesMatch ".(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=259200"
</FilesMatch> <FilesMatch ".(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch> </IfModule>
</IfModule>

2) 加入失效时间,没验证成功

开启模块:

LoadModule expires_module modules/mod_expires.so

服务器配置:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A600
ExpiresByType image/x-icon "access plus 2 month"
ExpiresByType application/x-javascript "now plus 2 day"
ExpiresByType text/css "now plus 2 day"
ExpiresByType image/gif "access plus 2 month"
ExpiresByType image/png "access plus 2 month"
ExpiresByType image/jpeg "access plus 2 month"
ExpiresByType text/plain "access plus 2 month"
ExpiresByType application/x-shockwave-flash "access plus 2 month"
ExpiresByType video/x-flv "access plus 2 month"
ExpiresByType application/pdf "access plus 2 month"
ExpiresByType text/html "now plus 1 day"
</IfModule>

最新文章

  1. 大众点评cat系统的搭建笔记
  2. redis入门配置
  3. ASP.Net MVC开发基础学习笔记(2):HtmlHelper与扩展方法
  4. Tom and paper
  5. JS的文本编辑框jwysiwyg-0.6
  6. 1041. Be Unique (20)
  7. [Swust OJ 179]--火柴棍(找规律)
  8. JavaScript的Cookie操作
  9. 对angularjs时间过滤格式
  10. 程序员/PM怎么让项目预估的时间更加准确
  11. win10下端口被占用解决办法
  12. org.hibernate.exception.SQLGrammarException: could not extract ResultSet &amp;&amp;&amp;&amp;&amp;Incorrect syntax near &#39;@P0&#39;.
  13. xtrabackup单表备份与恢复
  14. 吴恩达机器学习笔记33-评估一个假设输出(Evaluating a Hypothesis Outpute)
  15. rest api方式实现对文档库的管理
  16. idea : shorten command line
  17. 巧妙利用SVN 实现复制需要部署的文件。
  18. 树-二叉搜索树-AVL树
  19. 【第九周】psp
  20. HDU--1874

热门文章

  1. JS采用ActiveXObject实现用户在提交表单时屏蔽敏感词的功能
  2. CSS3学习系列之字体
  3. drozer使用
  4. [USACO07NOV]电话线Telephone Wire
  5. 流畅的python学习笔记第七章:装饰器
  6. strval
  7. 解决运行pytorch程序多线程问题
  8. tomcat7以上,ajax post参数后台获取不到的问题
  9. Django 学习笔记(二)
  10. ReOut