Seajs Study Notes

Source: Internet
Author: User

Seajs Study Notes

This article mainly introduces Seajs's knowledge and learning experience. It is suitable for those who are new to SeaJS. For more information, see

1. Introduction

 

Seajs is a Web module loading framework that pursues simple and natural code writing and organization methods. Sea. js complies with CMD specifications and is modularized with JS Code. The automatic dependency loading and configuration are concise and clear, allowing programmers to focus more on coding.

 

2. Advantages and Disadvantages

 

Advantages:

1). improve maintainability.

2). Modular programming.

3). Dynamic Loading and front-end performance optimization

 

Disadvantages:

1). Learning documents are less complex and confusing. This will change the team's JS writing habits and requires Modular programming.

2). It is not suitable for the current situation of the team. There are many JS files but few changes, and the advantage of dynamic loading and modularity is not obvious.

3). The SPM and JS packaging and management tools must be used together.

 

2. What are CMD and AMD?

 

Asynchronous Module Definition (AMD) is short for Asynchronous Module Definition, and is the standardized output of modules defined by RequireJS during the promotion process.

The general Module Definition (CMD) is the abbreviation of the Common Module Definition. It is the standardized output of the Module Definition in SeaJS during the promotion process.

Both RequireJS and SeaJS are representative of the modular framework. AMD and CMD are different in code style and API.

 

3. How to use it?

The Code is as follows: <script src = "../js/examples-master/sea-modules/seajs/2.1.1/sea. js"> </script>

<Script>

// Configure the js path

Seajs. config ({

Alias :{

"Jquery": "../examples-master/sea-modules/jquery/1.10.1/jquery. js"

}

});

// Load the module

Seajs. use ('../js/seajs/init', function ($ ){

$ ("# Test_div"). click (function () {alert (1 );});

});

</Script>

The Code is as follows:

// Init. js

Define (function (require, exports, module ){

Var $ = require ('jquery ');

Return $;

});

 

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.