Home Web Front-end JS Tutorial Seajs study notes_Seajs

Seajs study notes_Seajs

May 16, 2016 pm 04:57 PM

1. Introduction

Seajs, a Web module loading framework, pursues a simple and natural way of writing and organizing code: Sea.js follows the CMD specification and modularizes JS code. Automatic loading of dependencies and concise and clear configuration allow programmers to focus more on coding.

2. Advantages and disadvantages

Advantages:
1). Improve maintainability.
2). Modular programming.
3).Dynamic loading, front-end performance optimization

Disadvantages:
1). The learning documents are sparse and confusing, which will change the team’s writing habits of using JS, and modular programming must be used.
2). It is not suitable for the current situation of the team. There are many JS files but few changes. The advantages of dynamic loading and modularization are not obvious.
3). Requires the use of SPM tools, JS packaging and management tools.

2. What are CMD and AMD?

Asynchronous Module Definition (AMD) is the abbreviation of Asynchronous Module Definition, which is the standardized output of module definition during the promotion process of RequireJS.
Common Module Definition (CMD) is the abbreviation of Common Module Definition, which is the standardized output of module definition during the promotion process of SeaJS.
RequireJS and SeaJS are both representatives of modular frameworks. AMD and CMD are their respective ways of defining modularity. They are similar, mainly in coding style and API.

3. How to use?

Copy code The code is as follows:
<script src="../ js/examples-master/sea-modules/seajs/seajs/2.1.1/sea.js"></script>
<script>
//Configure js path
seajs.config ({
alias:{
"jquery":"../examples-master/sea-modules/jquery/jquery/1.10.1/jquery.js"
}
});
//Load module
seajs.use('../js/seajs/init',function($){
$("#test_div").click(function(){alert(1) ;});
});
</script>

Copy code The code is as follows:

//init.js
define(function(require,exports,module){
var $ = require('jquery');
return $;
});
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Replace String Characters in JavaScript Replace String Characters in JavaScript Mar 11, 2025 am 12:07 AM

Replace String Characters in JavaScript

Custom Google Search API Setup Tutorial Custom Google Search API Setup Tutorial Mar 04, 2025 am 01:06 AM

Custom Google Search API Setup Tutorial

Example Colors JSON File Example Colors JSON File Mar 03, 2025 am 12:35 AM

Example Colors JSON File

10 jQuery Syntax Highlighters 10 jQuery Syntax Highlighters Mar 02, 2025 am 12:32 AM

10 jQuery Syntax Highlighters

8 Stunning jQuery Page Layout Plugins 8 Stunning jQuery Page Layout Plugins Mar 06, 2025 am 12:48 AM

8 Stunning jQuery Page Layout Plugins

Build Your Own AJAX Web Applications Build Your Own AJAX Web Applications Mar 09, 2025 am 12:11 AM

Build Your Own AJAX Web Applications

What is 'this' in JavaScript? What is 'this' in JavaScript? Mar 04, 2025 am 01:15 AM

What is 'this' in JavaScript?

10  JavaScript & jQuery MVC Tutorials 10 JavaScript & jQuery MVC Tutorials Mar 02, 2025 am 01:16 AM

10 JavaScript & jQuery MVC Tutorials

See all articles