JS Front-end Modular loader principle Analysis (I.)

Source: Internet
Author: User

First of all, the value of the front-end modularity: The reference module is described here in detail and can be viewed on its own.

A. Summarize the following advantages:

(1) Resolving naming conflicts
(2) Cumbersome file dependencies
(3) version management of the module
(4) Improved maintainability
(5) Front-end performance optimization
(6) Cross-environment sharing module

Two. The basic idea of the loader:

How do we define our modules?

How do we merge the modules we define?

We think about, if we normal reference into the JS page we need to do God horse things, whether it is used: <script type= "text/javascript" src= "xxx" ></SCRIPT> then the question came, In fact, the thing we need to do is to dynamically construct the <script>, is it possible for the loader to implement this function?

In fact, this time we look at the above <script Src> Do we still need to know the address of our config JS file? This can be correctly introduced JS?

Here we are due to how to configure the address function ()

Did we mention that we solved the dependencies between modules? Well, we should know that since we are going to implement the dependencies between modules, we definitely need to know if the JS we rely on is already loaded. Here we need to realize whether JS loading complete function?

JS Front-end Modular loader principle Analysis (I.)

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.