RequireJS dependency instance (recommended) and requirejs instance

Source: Internet
Author: User

RequireJS dependency instance (recommended) and requirejs instance

Now let's take a look at the neat features of RequireJS:

The following is an html page:

At most one script statement introduces the require. js file and specifies another js file: config. js in data-main. Its definition is as follows:

require.config({   paths: {     "jquery": "../third_party/jquery-1.8.0.min",     "jquery.validate": "../../plugin/jquery-validation-1.9.0/jquery.validate",     "jquery.artDialog": "../../plugin/artDialog4.1.6/jquery.artDialog"   } });  require(["jquery"], function(util) {    require(["jquery.validate", "jquery.artDialog"], function(util) {      require(["masterUI", "masterSite", "configuration"], function(util) {                                                                      $(document).ready(function() {     window.configuration.init();       })     });   }); }); 

In require. config, configure the js File Location of the introduced third-party js library, including jquery, jquery. validate, and jquery. artDialog.

The next three require requests are called, with one layer. Note that the dependency sequence is the inner layer dependent on the outer layer. The first to be loaded is written to the outermost layer.

At the top of the page, we wrote a call, $ (document). ready (...), which was generally written in the html page. It is decoupled from html.

The above RequireJS dependency instance (recommended) is all the content shared by Alibaba Cloud xiaobian. I hope to give you a reference and support for the customer's home.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.