Modernizr.load 在 Firefox 中很慢
该脚本始终在页面加载时执行。我的问题是 JavaScript。从缓存(甚至服务器)加载资源需要很长时间。
Modernizr.load([{
load: 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js',
complete: function () {
if (!window.jQuery) {
Modernizr.load('@Url.Content("~/Public/Scripts/jquery-1.6.2.min.js")');
}
else {
global_scriptLoadingMonitor.complete();
}
}
},
{
load: '@Url.Content("~/Public/Scripts/templates.jst")'
},
{
load: '@Url.Content("~/Public/Scripts/jquery.validate.min.js")'
},
{
load: '@Url.Content("~/Public/Scripts/jquery.validate.unobtrusive.min.js")'
}];
当我检查这些东西如何加载时,我看到它在哪里加载了两次。在下图中,它首先加载上半部分(但显然,脚本实际上尚未加载),然后需要永远加载下半部分。
它在 Chrome 和 IE 上加载速度非常快。 Firefox 可能存在什么问题?
This script always gets executed on page load. My problem is with JavaScript. It takes forever to load the assets from cache (or even the server for that matter).
Modernizr.load([{
load: 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js',
complete: function () {
if (!window.jQuery) {
Modernizr.load('@Url.Content("~/Public/Scripts/jquery-1.6.2.min.js")');
}
else {
global_scriptLoadingMonitor.complete();
}
}
},
{
load: '@Url.Content("~/Public/Scripts/templates.jst")'
},
{
load: '@Url.Content("~/Public/Scripts/jquery.validate.min.js")'
},
{
load: '@Url.Content("~/Public/Scripts/jquery.validate.unobtrusive.min.js")'
}];
When I checked how the stuff loads, I see where it loads it twice. In the image below, it loads the top half first (but apparently, the script is not actually loaded yet), then it takes forever to load the bottom half.
It loads very fast on Chrome and IE. What could be the problem with Firefox?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Modernizr 实际上请求每个 Javascript 文件两次,依靠缓存使第二次请求瞬时完成。看看这个答案。
Modernizr actually requests each Javascript file twice, relying on the cache to make the second request instantaneous. Take a look at this answer.
问题出在扩展名为
.jst
的文件上。所以我只是将其更改为.js
。The problem was with the file with the extension
.jst
. So I just changed that to.js
.