Modernizr.load is slow in 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开发者_如何学Python.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?
Modernizr actually requests each Javascript file twice, relying on the cache to make the second request instantaneous. Take a look at this answer.
The problem was with the file with the extension .jst
. So I just changed that to .js
.
精彩评论