This article mainly targets javascript modularization for simple parsing. How to Write a module and load the module on the page, interested friends can refer to this article to explain the modularization of javascript. The specific content is as follows:
AMDThis is the standardized output defined by RequireJS in the promotion process.
Asynchronously load the module, depending on the front, and execute it in advance.
Define definition module define (['require ', 'foo'], function () {return });
Require loading module (dependent on the front) require (['foo', 'bar'], function (foo, bar ){});
CMDThis is the standardized output defined by SeaJS in the promotion process.
Define defines exports to export define (function (require, exports, module) {}); the module stores some objects on the current module.
Directly introduce require (./. Require. async asynchronous introduction.
Synchronous loading with nearby dependencies and delayed execution.
SeaJS Application
Official Entry Example: http://seajs.org/docs/#quick-start
How to Write a SeaJS module?
// All modules use define to define (function (require, exports, module) {// introduce the dependency var $ = require ('jquery ') through require '); var Spinning = require ('. /spinning '); // provides the interface exports through exports. doSomething =... // or use module. exports provides the entire interface module. exports = ...});
In the pageLoad Module
// At the end of hello.html, use the script to introduce sea. after js, there is a piece of configuration code: // seajs simple configuration seajs. config ({base :".. /sea-modules/", alias: {" jquery ":" jquery/1.10.1/jquery. js? 1.1.23 "}) // load the entry module seajs. use (" ../static/hello/src/main ")
The above is a brief introduction to javascript modularization, hoping to help you learn about javascript modularization.