0

I am struggling to get some performance in my MVC application.I am loading a partial page (popup) which is taking hardly 500ms. But each time the popup loads it also downloads 2 jQuery files as well. is it possible to use the jQuery from cache or from parent page?

I have attached the image in red which shows 2 additional request to server.

enter image description here

4

3 回答 3

1

弹出窗口是使用 iframe 还是只是将其内容添加到当前页面的 DOM 中?

如果它被添加到当前页面,您可以尝试将脚本引用添加到父页面。如果父页面不需要这两个文件,这可能并不总是最好的主意,但如果父页面也使用 jQuery 验证,那么弹出窗口将能够使用父页面对脚本文件的引用。

对于 iframe,我建议查看 Gzip 和缩小以使脚本加载更快。

于 2013-08-29T18:49:10.130 回答
1

为了提高性能,您可以尝试以下方法:

  1. 查看您的应用程序服务器是否支持 GZip 并配置应用程序/服务器以返回始终以 Gzip 存档的响应
  2. 使用缩小版的 JQuery
  3. 还有打包库,可以打包所有导入的资源,比如 CSS 文件和 JS 文件,浏览器对每种资源类型只做 1 个请求。例如,在 Java 中,我们有一个名为 packtag 的库。

一般来说,我建议您使用 Google Chrome 浏览器及其性能分析器。它会给你很好的提示。

于 2013-08-28T09:24:03.857 回答
1

在捆绑配置中使用此代码

BundleTable.EnableOptimizations = true;

并且还将这两个文件包含在单个包中。

于 2013-08-28T09:30:28.737 回答