有时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. zt-Simple source policy routing

    原文地址: http://tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.simple.html Linux Advanced Routing & Tr ...

  2. Echarts动态加载后台数据

    注意:1.用Ajax请求获取后台数据 2.Echarts只能处理Json数据 后台Controller:根据业务需求不同而返回不同数据,我前台要循环遍历Echarts的series进行数据添加,所以后 ...

  3. [PHP] php实现文件下载

    1. 设置超链接的href属性 <a href="文件地址"></a> 如果浏览器不能解析该文件,浏览器会自动下载.而如果文件是图片或者txt,会直接在浏览 ...

  4. 利用Java自带的MD5加密

    package test.md5; import java.security.MessageDigest; public class MD5Util { public final static Str ...

  5. ansible 2.2的源码编译安装

    ansible代码下载地址:http://releases.ansible.com/ansible/ # git clone git://github.com/ansible/ansible.git ...

  6. 使用MyBatis Generator自动创建代码

    SSM框架--使用MyBatis Generator自动创建代码 1. 目录说明 使用自动生成有很多方式,可以在eclipse中安装插件,但是以下将要介绍的这种方式我认为很轻松,最简单,不需要装插件, ...

  7. day5----模块

    1.定义     模块:用来从逻辑上组织python代码(变量,函数,类,运行逻辑:实现一个功能),本质就是.py结尾的python文件(文件名:test.py,对应的模块名:test)     包: ...

  8. halcon学习笔记——(11)Image,region,xld初步

    一 读取的3种方式: 读取单张的图片: read_image( image,'filename') //image 是输出对象,后面是输入文件的路径和名称 读取多图: 1,申明一个数组,分别保存路径 ...

  9. 【Windows 10 IoT - 2】LED闪烁及动画绘制(树莓派 Pi2)

    在上一篇博文<Windows 10 IoT系统安装>中,我们实现了在树莓派2平台上运行Window 10 IoT,本篇文章将介绍在该平台上的程序开发. 在最初获得的资讯中,以为Window ...

  10. Dynamic CRM 2013学习笔记(二十四)页面保存前进行逻辑验证

    我们有时要验证下页面上的一些逻辑,比如开始时间不能晚于结束时间,不对时不让保存.我们可以在相关的字段事件上处理,但这如果要判断的字段比较多时,就比较麻烦了. 这时候我们就可以利用Form的OnSave ...