require js超时分析以及解决方案

使用require js的同学经常会遇到timeout的问题



 

造成require js timeout的原因有如下几个:

(1)依赖死循环

 A depends on B, and B depends on A.

(2)网络慢导致js文件超时

解决方案:

(a)使用工具检查require js是否存在依赖循环


xrayquire
 (a tool by requirejs) can check for circular dependencies
 

(b)设置requirejs配置参数waitSeconds

 

waitSeconds: The number of seconds to wait before giving up on loading a script. Setting it to 0 disables the timeout. The default is 7 seconds.

参考:http://hw1287789687.iteye.com/admin/blogs/2238631

http://stackoverflow.com/questions/14279962/require-js-error-load-timeout-for-modules-backbone-jquerymobile

猜你喜欢

转载自hw1287789687.iteye.com/blog/2286224