Alibabacloud.com offers a wide variety of articles about modular programming with python, easily find your modular programming with python information here online.
As Web sites become "Internet apps," JavaScript code embedded in Web pages is growing larger and more complex.
Web pages are more and more like desktop programs, need a team division of work, progress management, unit testing and so on ... Developers have to use the software engineering approach to manage the business logic of Web pages.
JavaScript modular programming has become an urgent requirement. Id
As Web sites become "Internet apps," JavaScript code embedded in Web pages is growing larger and more complex.
Web pages are more and more like desktop programs, need a team division of work, progress management, unit testing and so on ... Developers have to use the software engineering approach to manage the business logic of Web pages.
JavaScript modular programming has become an urgent requirement. I
The first part of this series introduces the basic wording of the JavaScript module, and today describes how to use the module in a canonical manner.(next to the above)VII. Specification of modulesFirst think about why the module is important?Because of the module, we can more easily use other people's code, want what function, load what module.However, this has a premise, that is, we must write the module in the same way, otherwise you have your writing, I have my writing, it is not messy set!
NanyiDate: October 30, 2012The first part of this series introduces the basic wording of the JavaScript module, and today describes how to use the module in a canonical manner.(next to the above)VII. Specification of modulesFirst think about why the module is important?Because of the module, we can more easily use other people's code, want what function, load what module.However, this has a premise, that is, we must write the module in the same way, otherwise you have your writing, I have my wri
The first part of this series introduces the basic wording of the JavaScript module, and today describes how to use the module in a canonical manner. VII. specification of modules First think about why the module is important?Because of the module, we can more easily use other people's code, want what function, load what module.However, this has a premise, that is, we must write the module in the same way, otherwise you have your writing, I have my writing, it is not messy set! This is even m
As the site continues to iterate, the JS code is getting more and more, so the problem comes
The code is a bit messy
Naming conflicts
File dependencies more complicated
In order to solve these problems, modular development has emerged1. A simple demo, maintenance and expansion moduleMaintenance and expansion of modules must abide by a convention: open and close principleOpen to add, closed for modification2, third-party package d
As websites gradually become quot; Internet applications quot;, Javascript code embedded into webpages becomes increasingly large and complex. Web pages are getting more and more like desktop programs, requiring a team to work together, schedule management, unit testing, and so on ...... developers have to use software engineering methods to manage web pages... syntaxHighlighter. al
As websites gradually become "Internet applications", Javascript code embedded into webpages becomes increasingl
At present, there are two kinds of standard JavaScript modules: Commonjs and AMD. AMD is mainly introduced here, but will start from Commonjs. One, Commonjs 2009, American programmer Ryan Dahl created the Node.js project, which uses JavaScript language for server-side programming. This sign "JavaScript modular Programming" is officially born. Because frankly spea
are inherently asynchronous, and traditional CommonJS modules do not load properly in a browser environment.One of the solutions is to develop a server-side component that makes static analysis of the module code and returns the module to the browser side, along with its dependency list. This works well, but requires the server to install additional components and therefore adjusts a series of underlying architectures.Another approach is to encapsulate the module definition with a standard set
) {5IsReady =true;6Foobar = foo () +bar ();7 });8 9 return {Ten Isready:isready, One Foobar:foobar A }; -});In the above example, the IsReady property is false before Foo and bar do not load.There are currently two JavaScript libraries that implement the AMD specification: Require.js and Curl.js. Requirejs was created by James Burke, who is also the founder of the AMD specification.3. ConclusionCommonJS uses a server-first strategy to load modules synchronously, and tries to cover mo
" (augmentation).var Module1 = (function (mod) {MOD.M3 = function () {//...};return mod;}) (Module1);The code above adds a new method M3 () to the Module1 module and then returns the new Module1 module.In a browser environment, parts of the module are usually obtained from the web, and sometimes it is not possible to know which part is loaded first. If you use the previous section, the first part of the execution is likely to load a nonexistent empty object, then use the "wide magnification mode
First, the original wordingA module is a set of methods for implementing a specific function.Simply put the different functions (and the variables that record the state) together, even if it is a module.function M1 () {//...} function m2 () {//...}The above functions M1 () and M2 () to form a module. When used, call directly on the line.The disadvantage of this approach is obvious: "Pollute" the global variable, there is no guarantee that the variable name conflicts with other modules, and the m
jquery can be defined like this:
Shim: {
' Jquery.scroll ': {
Deps: [' jquery '],
Exports: ' JQuery.fn.scroll '
}
}
Seven, Require.js plug-inRequire.js also offers a range of plugins for specific functions.The Domready plugin allows the callback function to run after the page DOM structure has been loaded.
Require ([' domready! '], function (DOC) {
Called Once the DOM is ready
});
The text and image plug-ins allow require.js to load texts
HTML page resides. Of course, you can also declare BASEURL through configuration, which is detailed below.Note that the modules declared in the Data-main are loaded asynchronously, which means that if the page is followed by In the App.js:Requirejs.config ({Load module from Js/lib by defaultBASEURL: ' Js/lib ',If the module ID starts with the app, it will look in the Js/app directoryBut be careful not to add ". js", otherwise the paths rules will expirePaths: {App: '.. /app '}});Requirejs ([' j
In the previous page layout, if the page needs to have all HTML tags related to it, this causes a page with a lot of content, when you view the source file, it is inconvenient to compile and maintain a large string of code. In this case, you can think of writing different functional items in different
In the previous page layout
Then there must be
When there is a lot of content in a page, it is inconvenient to compile and maintain a large string of code when you view the source file, at this tim
plug-inRequire.js also offers a range of plugins for specific functions.The Domready plugin allows the callback function to run after the page DOM structure has been loaded.
Require ([' domready! '], function (DOC) {
Called Once the DOM is ready
});
The text and image plug-ins allow require.js to load texts and picture files.
Define ([
' Text!review.txt ',
' Image!cat.jpg '
],function (Review,cat) {
Console.log (review);
Document.body.appendChi
, has a shim property that is specifically designed to configure incompatible modules. Specifically, each module defines (1) The exports value (the output variable name), indicating the name of the external invocation of the module, and (2) An array of deps that indicates the dependency of the module.For example, the plugin for jquery can be defined like this:Shim: {' Jquery.scroll ': {deps: [' jquery '], exports: ' JQuery.fn.scroll '}}Seven, Require.js plug-inRequire.js also offers a range of p
Problem Description:https://edu.csdn.net/course/play/456/4808Banking system. CPP: Defines the entry point of the console application. #include "stdafx.h" #include Feelings:Data written to the hard disk (such as writing a text document) appears to be in effect after fclosesuch as the withdrawal after the "current balance", must be writtenfp = fopen ("D:\\code\\balance.dat", "W"), fprintf (FP, "%lf", diff), Fclose (fp), fp = fopen ("D:\\code\\balance.dat", "R"); FSCANF (FP, "%lf", balance);p rin
this:
Shim: {
' Jquery.scroll ': {
Deps: [' jquery '],
Exports: ' JQuery.fn.scroll '
}
}
Seven, Require.js plug-inRequire.js also offers a range of plugins for specific functions.The Domready plugin allows the callback function to run after the page DOM structure has been loaded.
Require ([' domready! '], function (DOC) {
Called Once the DOM is ready
});
The text and image plug-ins allow require.js to load texts and picture files.
difference in principleSea.js follows the CMD specification. The writing style is similar to node. JS's writing template code. Automatic loading of dependencies, simple and clear configuration. It's just lazy loading.Require.js follow AMD specs, CMD and AMD are basically the same, the biggest difference is that cmd is lazy to load, AMD is preloaded.Simply put, sea.js belongs to lazy loading, require.js belongs to preload.Here, by the way, extend the pros and cons of preloading and lazy loadingP
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.