惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Archives - TechRepublic
Security Archives - TechRepublic
O
OpenAI News
W
WeLiveSecurity
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Troy Hunt's Blog
L
LINUX DO - 最新话题
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Palo Alto Networks Blog
Project Zero
Project Zero
Attack and Defense Labs
Attack and Defense Labs
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Tor Project blog
Scott Helme
Scott Helme
T
Threat Research - Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
Spread Privacy
Spread Privacy
Cisco Talos Blog
Cisco Talos Blog
T
Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
Google DeepMind News
Google DeepMind News
P
Privacy & Cybersecurity Law Blog
Know Your Adversary
Know Your Adversary
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
Lohrmann on Cybersecurity
Cloudbric
Cloudbric
I
Intezer
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
AI
AI
B
Blog
S
Securelist
P
Proofpoint News Feed
量子位
Jina AI
Jina AI
V2EX - 技术
V2EX - 技术
T
The Exploit Database - CXSecurity.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
CERT Recently Published Vulnerability Notes
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - leavingme

从 Google Code 迁移代码到 GitHub 上 ActionScript 3 Socket 安装 VirtualBox Guest Additions 后 Windows XP 分辨率问题 Xcode 4.5的几个问题 Function Backbone.js WebGL Relearn jQuery 关闭脚本运行慢的提示 理解使用 JavaScript 构建 Metro 应用 iOS RSA相关资料 网站地图 Apache Ant & YUI Builder html5 manifest ie6下动态更改img.src 图片不显示 ApacheBench 锚点 空白的iframe 中文正则
CommonJS
leavingme · 2011-08-23 · via 博客园 - leavingme

转载自:http://www.grati.org/?p=165

JavaScript是一个强大面向对象语言,它有很多快速高效的解释器。官方JavaScript标准定义的API是为了构建基于浏览器的应用程序。然而,并没有定于一个用于更广泛的应用程序的标准库。

CommonJS API定义很多普通应用程序(主要指非浏览器的应用)使用的API,从而填补了这个空白。它的终极目标是提供一个类似PythonRubyJava标准库。这样的话,开发者可以使用CommonJS API编写应用程序,然后这些应用可以运行在不同的JavaScript解释器和不同的主机环境中。在兼容CommonJS的系统中,你可以实用JavaScript程序开发:

服务器端JavaScript应用程序
命令行工具
图形界面应用程序

混合应用程序(如,TitaniumAdobe AIR

NodeJSCommonJS之间的关系

CommonJS是一种规范,NodeJS是这种规范的实现。CommonJS是一 个不断发展的规范,计划将要包括如下部分:

具体每个子规范的定制进度请查看官方网站的说明:http://commonjs.org/specs/

CommonJS有很多实现,其中不乏很多大名鼎鼎的项目,比如 说:ApacheCouchDBnode.js等。但这些项目大 部分只实现了CommonJS的部分规范。具体的项目和实现部分参见官方网站的说明:http://commonjs.org/impl/

说两句:千万别小看作为后台应用的JavaScriptPalmWebOS的开发计划中就曾提到CommonJS和其扩展的JS API,另外几乎所有的平台(包括智能手机平台和计算机平台都开始流程)都开始引入Web技术:比如说S60中的WRTIPhone中的 WebWidgetAndroid平台上的WebWidget,还有Firefox直接用XMLCSS作界面用Javascript控制逻辑,甚至 GoogleChromeOS直接就是一个浏览器操作系统。  我做个技术上的赌注:动态语言和静态语言混合编程将会很流行(比如AndroidPalmWebOS同时引入两种SDKQT直至 QTScript)。

seajs 玉博 模块加载器

requirejs

豆瓣do

nodejs实现了commonjs约束

commonjs不是只有模块

requirejs api

usage 

有5种基本方式来使用require.js:

1. 载入脚本文件

2. 定义一个模块

3. 定义一个国际化bundle

4. specify a text file dependency

5. specify a jsonp service dependency