Using RequireJS in JavaScript applications for delayed loading

Source: Internet
Author: User
This article describes how to use RequireJS in JavaScript applications to implement delayed loading. JavaScript is a popular JavaScript library. if you need it, you can refer to simple and complex Web applications, it is composed of HTML, JavaScript, and CSS files. Developers usually use third-party JavaScript frameworks such as JQuery, Knockout, and Underscore to speed up development. Because these JavaScript frameworks are developed for specific purposes and have been "verified", it is more appropriate to use them directly than to implement the functions required from the beginning. However, with the increasing complexity of applications, it is increasingly important to write clean, low-coupling, and maintainable code. In this article, I will explain how the RequireJS framework helps application developers write more modular code and how it improves application performance by loading JavaScript files in a delayed manner.

In the beginning, we do not need to use the RequireJS framework, and then use RequireJS to reconstruct it in the next chapter.

The following HTML page contains a message

Element. When you access this page, it displays the order Id and customer name information.

The Common. JS file contains the definitions of two modules: Order and Customer. The showData function is combined with the page body. it calls the write function to put the information to be output into the page. As an example, I hardcoded Id 1 in the showData function, and the customer name is Prasad.

JavaScript NonRequireJS

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.