JQuery Source code Analysis and use experience-about the source code

Source: Internet
Author: User

When it comes to jquery, you might intuitively think that jquery's source code should be a jquery.xx.js file. But when we see the real source code, the whole people think of it. jquery's source code is far more than you think, in order to ensure the maintainability, robustness, versatility, and so on, jquery will separate the function modules into a single JS file, and through the dependency between the management module, At the time of construction through this dependency on the integration of the various modules into a JS file, finally through the compression confusion and other steps will produce the Jquery.xx.min.js file we often use (Q June: Come up and say these disgusting things, we do not understand to skip Ah!).

Source of Source:

Github:https://github.com/jquery/jquery

SOURCE version:

2.1.1:https://github.com/jquery/jquery/archive/2.1.1.zip

Directory structure:
/----build/   Some of the files used to build the jquery code----dist/     Build the resulting files----src/      source files , which is the main analysis of this series of articles----test/     test related , mainly in order to ensure the robustness of the code----other files     including grunt, Bower jshint related configuration

src/is the real code for jquery, which contains the various functional modules of jquery, and then we will step through each module.

Auxiliary Environment Construction:

Create an analysis directory under the root directory to aid in analyzing the source code, facilitate debugging, and observe some of the details of the operation.

During the analysis, I will create a lot of HTML to load the source code of the various modules. With core as an example, create a core.html

<!DOCTYPE HTML><HTML>    <Head>        <MetaCharSet= "Utf-8">        <title>Core</title>    </Head>    <Body>        <Scriptsrc= "Require.js"type= "Text/javascript"CharSet= "Utf-8"></Script>        <Scripttype= "Text/javascript"CharSet= "Utf-8">require (['.. /src/core.js'], function($) {Console.log ($); })        </Script>    </Body></HTML>

Require.js is a class library for AMD specifications, AMD is the asynchronous Module Definition (asynchronous module loading mechanism) that provides asynchronous loading and dependency management support. (q June: This is not CPU AMD!) jquery's source code uses AMD, or follows the Requirejs way to define each module, so we load the jquery module correctly with Requirejs.

More details can be found on REQUIREJS website: http://www.requirejs.org/

Attachment:

SOURCE +analysis Directory: Http://yunpan.cn/Q75WBaPr4RkT8 extract code 8469

JQuery Source code Analysis and use experience-about the source code

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.