1, first import the corresponding JS file Require.js is Requirejs library, Mian.js is used to write require configuration information, and index is to write their own logic code2. Write Mian.js configuration informationrequire.config ({ baseUrl:' js/',// definition with path paths:{ ' jquery ': ' jquery ', ' bootstrap ': ' Bootstrap.min ', ' utils ': ' Utils ' }, dependency, load boostrap before loading
: { ' underscore '_ ' }, ' Backbon E ': {deps: [' underscore ', ' jquery '' Backbone ' }} paths: { "jquery": "JQ Uery ", " underscore ":" Underscore " }}); 2.4AMD module notation The ① module must be defined using a specific define () function. If a module does not depend on other modules, it can be directly defined in the Define () function. define (function () {});② If the module also relies on other modules, then the first parameter of the Define () function must be an array that indicates th
Traditionally, loading JavaScript files is all about using
The above code will load 4 JavaScript files sequentially: Script1.js, Script2-a.js, Script2-b.js, and Script3.js. After loading the first three files, run two functions initScript1 () and InitScript2 (), and then run the function initScript3 () after loading the fourth file. Below, rewrite it with LABJS:
First, the $LAB object replaces the
Require () accepts two parameters, the first
These two days in understanding some of the front end of some use plug-ins, see a modular management of the JS plug-in Requirejs, to help the later project management and maintenance and optimization. By the way to learn a bit, the most basic configuration and reference methods recorded! The implementation effect is as follows: Reference file: Require.js
Among them, the page as long as the introduction of Require.js can, other so JS have module depen
REQUIREJS provides a packaged compression tool r.js to merge and compress the modules. R.js is very powerful, not only can compress js,css, can even package the whole project.
The R.js compression tool uses UGLIFYJS or closure Compiler. Default uses Uglifyjs (jquery also uses it to compress). In addition R.js needs to node.js environment, of course it can also run in the Java environment such as Rhino.
This article takes a simple example to feel t
Bo Master today, working in the work of JS Modular technology, here to a beginner tutorial, very easy to understand, to the same just get started you ~ ~Original address: http://www.ruanyifeng.com/blog/2012/11/require_js.htmlFirst, why use Require.js?At the earliest, all JavaScript code was written in a single file, as long as the file was loaded. Later, the code more and more, a file is not enough, must be divided into multiple files, loaded sequenti
Preach Wisdom Blog Video tutorial Download summary |java video tutorial |net video tutorial |php video tutorial | Web video Tutorial
Preach Wisdom Blog Video tutorial Download summary |java video
To cope with the increasingly complex, large-scale development of JavaScript. We piecemeal and simplify. The complex logic is divided into small units, conquer. At this time a project may have dozens of or even hundreds of JS files, each file is a
Original address: http://blog.csdn.net/xiaogou56a/article/details/21340213Define used to define modulesRequire used to load modules1Because defining a module may depend on other modules, and of course the simplest case is to not rely on other
Using the network, you can see that the order in which the browsers are loaded is:DOM = Require.js = Other.js = data-main= "Js/config"Config.js is usually loaded at the back of the other.js. Causes other.js not to get configuration information for
Preparing to use Angularjs + Require.js as the underlying framework for a new project, the following catalog results are just a preliminary idea:/default put the page, but for one page project , it may need to build a partials folder;/develop test
JavaScript does not have the concept of package management, there is no effective namespace mechanism, but through the Require.js library, it can be well implemented JS namespace management, to achieve the different JS module calls and
1, download the source version of the Jquery-ui, so you can load parts on demand
2. HTML page reference
3, the entrance file app.js
Require.config ({
BaseURL: "JS",
Paths: {
"jquery": "jquery",
},
Shim: {
}
});
Require (["jquery", "jquery-ui-1.
Aangular as a front-end development tool, by the vast number of front-end research and development personnel are well known, I from contact to now nearly two years of time, responsible for and angular related products have more than 10, have
The advanced Two article describes how r.js can compress all the modules into a single JS file or compress all the CSS into a CSS file via the command line. These include the use of some compression configuration parameters.But there are several
Objective Recently on the Internet, groups of all kinds of casual look, casually learn. Summer internship has not been found, yesterday opened a question, study well. Recently have seen the front-end of the Adm,cmd specification, and then on-line
Traditionally, the
The above code will load four JavaScript files in turn: script1.js, script2-a.js, script2-b.js and script3.js. After loading the first three files, run the two functions initscript1 () and
The advanced Two article describes how r.js can compress all the modules into a single JS file or compress all the CSS into a CSS file via the command line. These include the use of some compression configuration parameters.But there are several
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.