Seajs study notes_Seajs
May 16, 2016 pm 04:57 PM1. 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?
<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>
//init.js
define(function(require,exports,module){
var $ = require('jquery');
return $;
});

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Replace String Characters in JavaScript

Custom Google Search API Setup Tutorial

8 Stunning jQuery Page Layout Plugins
