This article mainly introduces the skills related to optimizing the RequireJS project. RequireJS is a JavaScript library for a person. If you need it, refer to this article to demonstrate how to merge and compress a RequireJS-based project. This article will use a painstaking tool, including Node. js. Therefore, if you do not have Node. js, click here to download
ObjectiveWhat problems can the front-end modularity solve?
Version management of the module
Improved serviceability-with modularity, you can make each file a single responsibility, very helpful for code maintenance
Load on demand-increase display efficiency
Better dependency processing-the traditional development model, if B relies on a, then you must first load a in front of the B file. If modularity is used, it is only required to declare dependencies within the module.
Some time ago, because some things this habit has fallen, now strive to pick up again.Recently began to self-study requirejs, in order to better grasp, so write a self-understanding of the blog for reference.Split Line-------------------------First of all, learn requirejs, to know what is Requirejs.The Requirejs is a very compact JavaScript module that can be run
Why study Requirejs?
such as my rookie, will mention a large amount of the article mentioned in AMD, JS Modular programming, asynchronous ... Wait a minute
Requirejs will allow you to write JavaScript in a different way than usual. You will no longer use the script tags to introduce JS files into HTML, and to manage dependencies without the script tag order.
Requirej
This article was reproduced from: http://www.cnblogs.com/kenkofox/p/4650310.htmlHowever, this article, I would like to further explore the advantages and disadvantages of these two frameworks, in addition, further, put aside these two frameworks, back to the real, and make a simple route to achieve a single page.This for just do the front-end development of the new classmate is the best, if one came to the post on a lot of angular, backbone, requirejs
What is Requirejs?
/* ---
Requirejs is a JavaScript module loader. It is ideal for use in browsers, it is ideal for use in browsers, but it can also be used in other scripting environments, like Rhino and Node. Loading a modular script with Requirejs will increase the load speed and quality of your code.
IE 6+ ..... Compatible?Firefox ..... Compa
1 OverviewRequirejs is a JS module loader that complies with AMD specifications. It is mainly to realize the asynchronous loading of JS file and the dependency between the management module. Here, let's take a look at the use of Requirejs.2 Requirejs the UseFirst, we create a project, the main file directory is as follows:2.1 Loading ModulesBefore using REQUIEJS Modular development, we need to download the
RequireJS is a very small JavaScript module loading framework and one of the best practitioners of AMD specifications. YII is currently the most popular PHPMVC framework. The following describes how to use RequireJS in YII to introduce RequireJS into registerScriptFile. RequireJS is a very small JavaScript module loadi
JS modular Development (requireJS)
Advantages of modular development:Expose interface through exports. This means that no namespace is required, and no global variables are required. This is a thorough solution to naming conflicts.Use require to introduce dependencies.This enables built-in dependencies. Developers only need to care about the dependencies of the current module. Other tasks such as Sea. js/Require. js will be automatically handled. For
Read Catalogue
First, Amendment 1:
Ii. Amendment 2:
Third, Revision 3:
Read Catalogue
Gulp resolving front-end cache issues for REQUIREJS projects (ii)
Objective
2, modify the Require.js
3. Modify Gulp-rev and Gulp-rev-collector
4. Testing
5. Summary
Back to the table of contents prefaceIn this section, we primarily address several of the issues mentioned at the end of the previous sectio
Objective
The advent of Requirejs makes the front-end code modularization easy, the current end of the project more and more, more and more code, modular code to make the project structure clearer, not only in the development of our ideas clearer, but also easier to maintain later. Here is a simple drawing program that I developed using Requirejs after learning Require
HTML5 boilerplate with requirejstable of contents
HTML5 boilerplate with Requirejs
Table of Contents
Code Base HTML5 Boilerplate
Code Base in Browser
Requirejs
Install
Configure
Multiple pages
Jscommonjs
Update Jsmainjs for indexhtml
Page1html
i18n
The Requirejs API exists under the namespace Requirejs created when Requirejs is loaded. The main API is the following three functions:
define– The function user creates the module. Each module has a unique module ID, which is used for Requirejs run-time functions, and the Define function is a global function tha
Because the recent project wants to reality a single page function, with the react, and then looked at the react route, dug slot gzip 16k? Then I wrote a simple single page (a single page that doesn't support multiple pages, and all the entrances go through rewrite to index.html), more than 200 lines (followed by GitHub).Then the project is packaged with Webpack, found that the Webpack require.ensure does not support variable loading (at least temporarily not found), that means I have a small nu
Most of the projects use modular development, Requirejs as an example of AMD module development, so it is necessary to learn. Through a step-by-step use of Requirejs to write demo, so as to learn the requirejs of a whole development process and the self-use requirejs some of the feelings.
AMD: A module-based asynchron
As a front-end modular design and loading framework, we should have a good understanding.Reference We need to quote jquery,underscore,backbone.Require.config ({BASEURL: ' JS basic path ',//Can be ignoredPaths: {' jquery ': ' Jquery.min ',' Underscore ': ' Underscore ',' Backbone ': ' Backbone '}});Require ([' jquery ', ' underscore ', ' backbone '],function ($,_,backbone) {Callback TODO});The most important point we use is the modular design, which is similar to the back-end Nodejs modularityMod
Introduction to simple Plotting Program Development in RequireJS
The emergence of RequireJS makes it easy to modularize the front-end code. When the front-end project grows and the code grows, the modular code makes the project structure clearer, not only makes our ideas clearer during development, in addition, it is easier to maintain it later. The following is a simple plotting program developed by using
1. About requirejs is a framework for Asynchronously loading js modules. 2. how to use it first go TO the official website TO download requirejs. then introduce 1 noticed the data-main attribute. A simple understanding is an entry function used to start the script loading process. Tip: to make this file load without losing its response, you can choose to load it at the bottom of the web page, another way i
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.