CommonJS,AMD和RequireJS之间的关系?

本文翻译自:Relation between CommonJS, AMD and RequireJS?

I'm still very confused about CommonJS, AMD and RequireJS. 我对CommonJS,AMD和RequireJS仍然很困惑。 Even after reading a lot. 即使阅读了很多。

I know that CommonJS (formerly ServerJS) is a group for defining some JavaScript specifications (ie modules) when the language is used outside the browser. 我知道CommonJS(以前称为ServerJS)是用于在浏览器之外使用该语言时定义一些JavaScript规范(即模块)的组。 CommonJS modules specification has some implementation like Node.js or RingoJS, right? CommonJS模块规范有一些实现,例如Node.js或RingoJS,对吗?

What's the relation between CommonJS, Asynchronous Module Definition (AMD) and RequireJS? CommonJS,异步模块定义(AMD)和RequireJS之间有什么关系? Is RequireJS an implementation of CommonJS module definition? RequireJS是CommonJS模块定义的实现吗? If yes, what's AMD then? 如果是,那么AMD是什么?


#1楼

参考:https://stackoom.com/question/17JzL/CommonJS-AMD和RequireJS之间的关系


#2楼

CommonJS is more than that - it's a project to define a common API and ecosystem for JavaScript. CommonJS不仅限于此-它是一个为JavaScript定义通用API和生态系统的项目。 One part of CommonJS is the Module specification. CommonJS的一部分是模块规范。 Node.js and RingoJS are server-side JavaScript runtimes, and yes, both of them implement modules based on the CommonJS Module spec. Node.js和RingoJS是服务器端JavaScript运行时,是的,它们都基于CommonJS Module规范实现模块。

AMD (Asynchronous Module Definition) is another specification for modules. AMD (异步模块定义)是另一种模块规范。 RequireJS is probably the most popular implementation of AMD. RequireJS可能是AMD最受欢迎的实现。 One major difference from CommonJS is that AMD specifies that modules are loaded asynchronously - that means modules are loaded in parallel, as opposed to blocking the execution by waiting for a load to finish. 与CommonJS的主要区别在于,AMD指定模块是异步加载的-这意味着模块是并行加载的,而不是通过等待加载完成来阻止执行。

AMD is generally more used in client-side (in-browser) JavaScript development due to this, and CommonJS Modules are generally used server-side. 因此,AMD通常更多地用于客户端(浏览器)JavaScript开发中,而CommonJS模块通常用于服务器端。 However, you can use either module spec in either environment - for example, RequireJS offers directions for running in Node.js and browserify is a CommonJS Module implementation that can run in the browser. 但是,您可以在任何环境中使用任何一个模块规范-例如,

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值