我可以在网络工作者中加载AMD模块吗
Can I load AMD modules inside a webworker?
我正在尝试让计算量大的Javascript真正实现并行。然而,我有一个问题,我所有的javascript文件都是AMD模块。我可以在我的网络工作者内部使用requirejs吗?怎样
在Web工作者中,可以使用importScripts
函数加载其他脚本。RequireJS的源代码显示也支持Web工作者:
// Line 23:
isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
// Line 1877:
} else if (isWebWorker) {
//In a web worker, use importScripts. This is not a very
//efficient use of importScripts, importScripts will block until
//its script is downloaded and evaluated. However, if web workers
//are in play, the expectation that a build has been done so that
//only one script needs to be loaded anyway. This may need to be
//reevaluated if other use cases become common.
importScripts(url);
相关文章:
- 如何将多个 AMD 模块捆绑在一个文件中
- AMD 模块中的动态导出
- 使用 Babel 将 ES6 模块转换为 ES5 AMD 模块,无法按预期工作
- JavaFX+Javascript:如何将Java对象注入AMD模块
- Javascript应用程序作为具有外部依赖关系的AMD模块
- 如何将预编译的hogan.js模板封装到AMD模块中
- 当混合node和amd模块时,requirejs()返回undefined
- 如何创建一个结构化为AMD模块的可重用库
- 我可以在网络工作者中加载AMD模块吗
- 如何从TypeScript编译中现有的AMD js类继承到AMD模块
- 使用磁带/ES6 单元测试测试 AMD 模块
- 如何将 AMD 模块从单例转换为实例
- 为什么串联的 RequireJS AMD 模块需要一个加载器
- 如何从道场层加载 AMD 模块
- 从前台检索后台页面的 AMD 模块
- 配置需要 js 才能在 javascript 中加载 AMD 模块
- 如何使用 tsc 从打字稿生成 amd 模块
- 如何使用jspm/system.js正确加载本地AMD模块
- Davis.js作为AMD模块
- RequireJS-在require流和内联中加载AMD模块