有时Requirejs会遇到加载js超时问题

除了排查js脚本问题,网络问题以外的一个解决方法是加大Require的等待时间waitSeconds,或者直接设置为0,这个参数的意义是: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.

引用别的帖子:

Load timeout for modules, Likely causes and fixes:

There was a script error in one of the listed modules. If there is no script error in the browser's error console, and if you are using Firebug, try loading the page in another browser like Chrome or Safari. Sometimes script errors do not show up in Firebug.

The path configuration for a module is incorrect. Check the "Net" or "Network" tab in the browser's developer tools to see if there was a 404 for an URL that would map to the module name. Make sure the script file is in the right place. In some cases you may need to use the paths configuration to fix the URL resolution for the script.

The paths config was used to set two module IDs to the same file, and that file only has one anonymous module in it. If module IDs "something" and "lib/something" are both configured to point to the same "scripts/libs/something.js" file, and something.js only has one anonymous module in it, this kind of timeout error can occur. The fix is to make sure all module ID references use the same ID (either choose "something" or "lib/something" for all references), or use map config.

解决方法:

  <script src="scripts/require.js"></script>
<script>
require.config({
baseUrl: "/another/path",
paths: {
"some": "some/v1.0"
},
waitSeconds: 0
});
require( ["some/module", "my/module", "a.js", "b.js"],
function(someModule, myModule) {
//This function will be called when all the dependencies
//listed above are loaded. Note that this function could
//be called before the page is loaded.
//This callback is optional.
}
);
</script>

相关链接:

1.http://stackoverflow.com/questions/8582314/requirejs-and-text-plugin-load-timeout-for-modules
2.http://stackoverflow.com/questions/20288007/load-timeout-for-modules-with-requirejs
3.官网API文档:http://requirejs.org/docs/api.html#define
4.中文API文档:http://requirejs.cn/docs/api.html#define
5.中文API文档:http://makingmobile.org/docs/tools/requirejs-api-zh/#define
6.中文文档:http://www.zfanw.com/blog/require-js.html
7.中文文档:http://www.fanli7.net/a/bianchengyuyan/ASP/20130419/300243.html
8.http://requirejs.org/docs/api.html#config-waitSeconds

Requirejs加载超时问题的一个解决方法:设置waitSeconds=0的更多相关文章

  1. springboot+thymeleaf刨坑——首页加载js/css等失败解决方法

    在使用thymeleaf加载css或js样式,当我们进入登录页的时候发现,所有的样式都是加载失败的.原因是在新版中有这样一个坑……: 当我们设置了addInterceptors-注册拦截器的时候,通常 ...

  2. AsyncTasLoader不进行加载操作的原因及解决方法

    使用AsyncTaskLoader加载数据.但是LoadInBackground却不会被回调.这是什么情况?我要怎么解决这个问题?如果你和我一样有这样的疑问.你可以移步至我的blog的这篇文章找到答案 ...

  3. 不同网段无法加载ArcGIS Server发布服务解决方法

    问题描述: ArcGIS Server 10发布的服务, (1)在相同网段的Desktop9.3和Engine 9.3程序下可以正常显示, (2)在不同网段Desktop9.3和Engine 9.3程 ...

  4. JAVA之中出现无法加载主类的情况解决方法

    j今天打代码的时候出现了无法加载主类的情况,我就收集了一些,java无法加载主类的方法 ava无法加载主类解决办法 今天启动项目,又遇到找不到或无法加载主类的情况,清除项目后无法编译,class文件下 ...

  5. Winform使用ML.NET时无法加载 DLL“CpuMathNative”问题的解决方法

    同样的代码运行在netcore下可以,运行在winform中就出现错误: 引发的异常:“System.DllNotFoundException”(位于 Microsoft.ML.Data.dll 中) ...

  6. linux 运行时加载不上动态库 解决方法(转)

    1. 连接和运行时库文件搜索路径到设置     库文件在连接(静态库和共享库)和运行(仅限于使用共享库的程序)时被使用,其搜索路径是在系统中进行设置的.一般 Linux 系统把 /lib 和 /usr ...

  7. Django中加载static无法成功的解决方法

    我试着进入/admin/ 结果它的/static/ 能够正常找到目标文件…真是日了哈*奇了. 我的link标签href=/static/…. 并没有什么问题 试着在urls中加入下面代码,但是没什么用 ...

  8. vue 动态加载图片路径报错解决方法

    最近遇到图片路径加载报错的问题 之前一直都是把图片放到assets的文件下的.总是报错,看到一些文章并且尝试成功了,特意记录下 首先先说明下vue-cli的assets和static的两个文件的区别, ...

  9. 在eclipse中启动tomcat加载不了项目的解决方法

    一.在server视图右键选择Add and Remove时,如果想要部署的项目不在左侧的待选列表中,或是弹出警告There are no resources that can be added or ...

随机推荐

  1. 360极速浏览器UA怪异以及如何用js判断360浏览器

    本文最后一次更新于7个月前,文章内容可能略有出入.若发现文章中有错误之处,可以留言评论告诉作者. 1.360极速浏览器UA因域名不同而异 今天在写一个判断浏览器.浏览器版本.操作系统.操作系统版本.浏 ...

  2. [转]深入理解mysqldump原理 --single-transaction --lock-all-tables --master-data

    本文转至:http://blog.csdn.net/cug_jiang126com/article/details/49824471 在mysqldump过程中,之前其实一直不是很理解为什么加了--s ...

  3. Python动态生成变量

    Python 也可以像javascript那样动态生成变量.我们看javascript的动态生成变量. var obj = {}; for (var i =0, len = 10; i < le ...

  4. Android webview 上传文件不调用openFileChooser解决办法

    html页面带有图片上传功能,关于使用openFileChooser方法去选择图片,并且在onActivityResult方法里面设置返回的图片url文件路径,网上有很多,再次不再赘述. 实践中发现, ...

  5. tomcat 协议之并发协议 Http11NioProtocol

    关于此协议的原理是什么尚不明确,待后续学习,但是该协议(Http11NioProtocol)能够改善高并发时tomcat的性能. 默认为HTTP/1.1,也就是阻塞式,在改用org.apache.co ...

  6. ubuntu下配置安装PYQT4

    apt-get安装(快) sudo apt-get install libxext6 libxext-dev libqt4-dev libqt4-gui libqt4-sql qt4-dev-tool ...

  7. sql语句对数据库表进行加锁和解锁

    锁是数据库中的一个非常重要的概念,它主要用于多用户环境下保证数据库完整性和一致性. 我们知道,多个用户能够同时操纵同一个数据库中的数据,会发生数据不一致现象.即如果没有锁定且多个用户同时访问一个数据库 ...

  8. gromacs, quake III和vrsqrtps

    看标题大家可能觉得三个词汇风马牛不相及,第一个是解蛋白质分子动力学的软件,第二个是上三代宅男最爱雷神之锤,第三个则是一个存在于IntelSSE及AVX中的一个指令,他的作用是快速求平方根的倒数. 起因 ...

  9. php数据库常用函数

    //打开mysqlmysql_connect( $host, $user, $pwd ) or die('error');$host => localhost //数据库地址$user => ...

  10. 实际遭遇并解决:类型“ASP.global_asax”同时存在的问题

    将一个ASP.NET项目由预编译方式改为动态编译方式时,删除了bin文件夹中所有扩展名为.compiled文件以及文件名以App_Web_开头的文件. 访问却出现下面的错误: System.Web.H ...