This article describes the loading processing of module dependencies in seajs. Share it for your reference, as follows:
Recently, I found some module dependencies issues when working on projects, and I will record them:
For example, there are 3 existing files:
/**/ define(function(require, exports, module){ require('jquery'); require(''); }) /**/ define(function(require, exports, module){ require('jquery'); require(''); //code... }) /**/ define(functioin(require, exports, module){ require('jquery'); //code... })
For example, when executing, , will depend on jquery. So how does seajs handle jquery in this case? Only execute once? Execute multiple times? Or another way?
Here we refer to Yu Bo's answer:
I'm rightThe understanding of module calls is that calling refers to obtaining the interface of a certain module.. In SeaJS,Only , , and require will generate module calls,for example:var a = require('./a')
existWhen executing require('./a'), the module's interface will be obtained. If it is called for the first time, module a will be initialized. When it is called later, the module a will be directly returned to the module a interface.; define is just the module information registered, such as after packaging:define(id, deps, factory)
It is to register a module into , define similar to:[id] = { id: id, dependencies: deps, factory: factory }
It is pure registration information.
andrequire('./a')
Only when['a'].factory
, after execution['a'].exports
Extension: The difference between URI and URL
URI:Uniform Resource Identifiers, Uniform Resource Identifier;
URL:Uniform Resource Locators, unified resource locators;
URN:Uniform Resource Names, Uniform Resource Name
URL, URN is a subset of URI.
refer to
Specific meaning: /seajs/seajs/issues/303
Distinguish between URI, URL and URNhttp:///developerworks/cn/xml/
For more information about JavaScript, readers who are interested in reading this site's special topic:JavaScript extension skills summary》、《Summary of JavaScript characters and string operation techniques》、《Summary of JavaScript mathematical operations usage》、《Summary of json operation skills in JavaScript》、《Summary of JavaScript Errors and Debugging Skills"and"Summary of JavaScript data structure and algorithm techniques》
I hope this article will be helpful to everyone's JavaScript programming.