且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何减少使用Javascript / jQuery的/ AJAX加载时间为我的网站?

更新时间:2023-12-04 22:37:58

速度性能由谷歌PageSpeed​​ 提出以下建议对JavaScript:

Speed performance by Google PageSpeed suggests the following for JavaScript:

Minifying the following JavaScript resources could reduce their size by 33KiB (29% reduction).
Minifying http://maavankal.com/source/jquery.fancybox.js?v=2.1.3 could save 16.6KiB (36% reduction).
Minifying http://maavankal.com/js/jquery.simplyscroll.js could save 3.4KiB (29% reduction).
Minifying http://maavankal.com/js/jcarousellite.js could save 2.7KiB (52% reduction).
Minifying http://maavankal.com/js/content_switch.js could save 1.9KiB (30% reduction).
Minifying http://maavankal.com/js/bgStretch.js could save 1.6KiB (37% reduction).
Minifying http://maavankal.com/js/cScroll.js could save 1.6KiB (33% reduction).
Minifying http://maavankal.com/js/forms.js could save 1.4KiB (26% reduction).
Minifying http://maavankal.com/js/jquery-ui.js could save 1KiB (5% reduction).
Minifying http://maavankal.com/.../jquery.fancybox-buttons.js?... could save 1KiB (35% reduction).
Minifying http://maavankal.com/js/superfish.js could save 946B (26% reduction).
Minifying http://maavankal.com/js/script.js could save 883B (18% reduction).

其他建议:

  • 尝试避免使用多发$(文件)。就绪语句
  • 使用jQuery的1.9.x的最新版本
  • 您使用了大量的插件。你可以将你的插件/脚本到1文件,你可以做到这一点很容易使用谷歌关闭编译器
  • 将你的内联标签到身体的末端(包括一些花哨的盒子),这些可能增加的DOM
  • 的加载时间
  • Utilise DOM缓存在你的jQuery code
  • 检查缺少的媒体(如图像)可以停止你的网页的加载。是/images/bg.jpg不见了?
  • 使用网络面板镀铬开发工具来分析你的网页的媒体的加载时间
  • Try avoid using mutiple $(document).ready statements
  • Use the latest version of jQuery 1.9.x
  • Your using a lot of plugins. You could combine your plugins/scripts into 1 file you can do this very easily using Google Closure compiler.
  • Move your inline tags to the end of the body (some including fancy box) these may increase the loading time of the dom
  • Utilise DOM caching in your jQuery code
  • check for missing media (such as images) may halt the loading of your page. is /images/bg.jpg missing?
  • Use the network panel in chrome dev tools to analyse loading times of your page media