JS Modular Library SEAJS Experience

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.