偶尔IE 9无法加载JavaScript资源

5

有时候当我加载我的网站时,大约五次中有一次会加载失败,在IE 9控制台中显示:

SCRIPT5007: Unable to get value of the property 'normalize': object is null or undefined 
require.js, line 929 character 25
SCRIPT5007: Unable to get value of the property 'normalize': object is null or undefined 
require.js, line 929 character 25
SCRIPT5007: Unable to get value of the property 'extend': object is null or undefined 
Module.js?ts=@@timestamp, line 52 character 3
SCRIPT5007: Unable to get value of the property 'normalize': object is null or undefined 
require.js, line 929 character 25
SCRIPT5007: Unable to get value of the property 'View': object is null or undefined 
View.js?ts=@@timestamp, line 8 character 3
SCRIPT5007: Unable to set value of the property 'Validation': object is null or undefined 
backbone.validation.js?ts=@@timestamp, line 15 character 3
SCRIPT5007: Unable to get value of the property 'extend': object is null or undefined 
Class.js?ts=@@timestamp, line 10 character 3
SCRIPT5007: Object expected 
hbs.js?ts=@@timestamp, line 143 character 15
SCRIPT5007: Object expected 
hbs.js?ts=@@timestamp, line 143 character 15
SCRIPT5007: Object expected 
hbs.js?ts=@@timestamp, line 143 character 15
SCRIPT5022: Load timeout for modules: css!lib/foundation/style_unnormalized2,css!lib/icon-font/fontcustom_unnormalized3,css!lib/icon-font/icon-font_unnormalized4,hbs!modules/header/HeaderTemplate_unnormalized5,css!modules/header/HeaderStyle_unnormalized6,hbs!lib/components/avatar/AvatarTemplate_unnormalized7,css!lib/components/avatar/AvatarStyle_unnormalized8,hbs!modules/login/LoginTemplate_unnormalized9,css!modules/login/LoginStyle_unnormalized10,hbs!modules/header/HeaderTemplate,hbs!lib/components/avatar/AvatarTemplate,hbs!modules/login/LoginTemplate
http://requirejs.org/docs/errors.html#timeout
require.js, line 1758 character 9

令人困惑的是它只是偶尔发生,可能是因为我要求JavaScript文件的方式不正确?


可以展示一下你是如何加载文件的,这样会很有用。能否提供一些代码? - Simon Smith
可能模块依赖关系没有正确设置? - Amy
1
这听起来像是你的依赖关系没有正确设置。五次中有四次,你的浏览器可能会加载脚本得足够快,以至于它可以正常工作,但偶尔也会出现问题。和任何问题一样:请在提问时附上代码,否则很难提供帮助。 - Christof
1个回答

0

这似乎与JQuery中发生的类似问题有关。

这都是关于DOM没有准备好,因为DOM没有完全加载,所以会出现这个错误,这也可以解释你提到的“随机”行为。

如果您还没有尝试过,请将脚本添加到页面末尾或某种懒加载方式:

顺便说一下,只是在这方面发布的帖子,微软拒绝了它,认为这不是一个错误:

https://connect.microsoft.com/IE/feedback/details/792880/document-readystat


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接