First contact with JSrequire. js modular tool_javascript skills

Source: Internet
Author: User
First contact with JSrequire. this article introduces the js modular tool require. in the first lesson of the js tutorial, I learned about require. js, write require. js, interested friends can refer to as the Website Functions gradually become more and more complex and bloated js in the web page, the original use of script tags to import js files is no longer able to meet the current Internet development model, we need team collaboration, module reuse, unit testing and a series of complex requirements.

RequireJS is a very small JavaScript module loading framework and one of the best practitioners of AMD specifications. The latest version of RequireJS is compressed with only 14 kb, which is very lightweight. It can work with other frameworks at the same time. Using RequireJS will definitely improve the quality of your front-end code.

What are the benefits of requirejs?

Official description of requirejs:

RequireJS is a JavaScript file and module loader. it is optimized for in-browser use, but it can be used in other JavaScript environments, like Rhino and Node. using a modular script loader like RequireJS will improve the speed and quality of your code.

Meaning:

In the browser, it can be used as a module loader for js files, or in the Node and Rhino environments, balabala .... This section describes the basic function "modular loading" of requirejs. What is modular loading? We will explain one by one from the subsequent sections

Let's take a look at a common scenario and explain how to use requirejs through examples.

Normal writing mode
Index.html:

   
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.