Seajs
Http://seajs.org/docs/en.html#intro
Https://github.com/seajs/seajs/releases
extremely simple experience of modular development
Why use
sea.js?
Sea.js ' s pursuit of a simple, natural coding and organization,has the following key aspects:
- The definition of a module specificationis simple and friendly: sea.js follow the CMD specification,as the NODE.J s module style.
- Natural and intuitive code organization: Automatically load dependence, configuration is simple and clear,so We can more enjoy coding.
Sea.js provides common plug-ins,they is very helpful for the development of debugging and performance Optimization,and ha s a rich extensible interface.
The declaration of the module is very simple and friendly.
Natural and intuitive way to organize your code. Automatic reliance on download and configuration is straightforward.
Compatibility:
compatibility
Sea.js have perfect test cases, compatible with all major browsers:
Chrome ? Firefox ? Safari 3.2+ ? Opera ? IE 5.5+ ?
Sea.js can is run in Mobile terminal,including Hybrid Mode App. In theory, Sea.js can is run in any browser.
Cmd
http://wiki.commonjs.org/wiki/Modules/1.1.1
CMD specification Module definition Format
//Inside b.js:define(function(require, exports, module) { //If "a" has used exports, then we have a real //object reference here. However, we cannot use //any of "a"‘s properties until after "b" returns a value. var a = require("a"); exports.foo = function () { return a.bar(); };});
AMD Specifications:
Http://www.requirejs.org/docs/api.html#funcmodule
//Inside b.js:define(["require", "a"], function(require, a) { //"a" in this case will be null if "a" also asked for "b", //a circular dependency. return function(title) { return require("a").doSomething(); } });
Experiment
Https://github.com/fanqingsong/code-snippet/tree/master/web/seajs_demo
One.js
Inside One.js:
Define (function (Require, exports, module) {
var = require ('./two.js ');
Exports.sayhello = function () {
Console.log (' one module called ');
};
Exports.calltwo = function () {
Two.sayhello ();
};
}
);
Two.js
Inside Two.js:
Define (function (Require, exports, module) {
Exports.sayhello = function () {
Console.log (' Both module called ');
};
}
);
Demo.html
<!--This sets the BASEURL to the " Scripts "directory, and
loads a script that Would have a module ID of ' main '-->
<script src= "./sea.js" ></ Script>
<style>
</style>
<script>
Seajs.use (' One ', function (one) {
One.sayhello ();
One.calltwo ();
});
</script>
<body>
</body>
More straightforward and easier to use than Requirejs.
JS Modular Library SEAJS Experience