This article mainly introduced SEAJS knowledge and learning experience, suitable for just contact Seajs classmate, need friends can refer to, have better novice tutorials or documents, welcome to recommend, Share!
1.
Seajs IntroductionSeajs, a Web module loading framework, the pursuit of simple, natural code writing and organization,: Sea.js Follow the CMD specification, modular JS code. Relying on automatic loading, simple and clear configuration, allows programmers to focus more on coding. 2.
Seajs Advantages and disadvantagesAdvantages: 1. Improve maintainability. (2). Modular programming. 3. Dynamic loading, front-end performance optimization disadvantages: 1. Learning less and confusing documents will change the writing habits of the team using JS, and you must use modular programming. 2). Not very suitable for the current situation of the team, more JS file but less changes, dynamic loading advantages and modularity advantage is not obvious. 3. Need to support the use of SPM tools, JS packaging and management tools. 2.
what is cmd and AMD? Asynchronous module definition (AMD) is the abbreviation of Asynchronous module definition, and it is the normalized output of requirejs in the process of generalization. Universal module definition (CMD) is the abbreviation of Common module definition, and it is the normalized output of seajs in the process of generalization. Both Requirejs and SEAJS are representatives of modular frameworks, AMD and CMD, which are their respective ways of defining modularity, the same as the code style and API. 3.
Seajs How to use?
A piece of code to teach novice at a glance, Quick start!
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> code as follows://init.js define (function (Require,exports,module) {var $ = require (' jquery '); return $; });
Seajs is so simple, quick to learn it!