Front-end learning-jQuery source code learning, front-end-jquery source code

Source: Internet
Author: User

Front-end learning-jQuery source code learning, front-end-jquery source code

Compared with jQuery 1, jQuery 2 does not have to consider IE6, 7, or 8 compatibility. Therefore, if you do not need to consider IE6, 7, or 8, jQuery 2 is used, if you need to consider IE6, 7, and 8, use jQuery 1.

A jQuery object is a special array of DOM objects and contains a large number of methods. It can be understood:

   

function jQuery(){

    var jquery = [dom1, dom2, dom3];

    jquery.fn1 = function(){…};

    jquery.fn2 = function(){…};

    return jquery;

}

 

 

The essence of jQuery source code: initialization design ideas, selector design methods, event processing design methods, animation effect design mechanisms, ajax encapsulation design ideas, plug-in mechanism design, design methods for compatibility processing.

JQuery-2.0.3.js source code a total of 8829 lines, the following parts of each part of the function to make a simple summary.

   

(14) rows 14th to 8829, (function (window, undefined) {}) (); custom anonymous function execution, all source code is included in the anonymous function.

(21, 94) defines some variables and functions jQuery = function (){};

(96,283) jQuery. fn = jQuery. prototype = {...}; JQuery. fn. init. prototype = jQuery. fn; prototype is the prototype of the jQuery object. It is mainly used to add methods and attributes to the JQ object.

(285,347) extend: The Inheritance Method of JQ, which provides good scalability for subsequent code addition, and also extends the extension plug-in from this inheritance. JQuery. extent = jQuery. fn. extent = function (){...};

(349,817) jQuery. extend ({...}); Extends some tool methods (static methods), such as $. trim () and $. proxy.

(877,285 6) Sizzle: implementation of complex selectors

(2880,304 2) Callbacks: callback object: unified management of functions, add, remove, has, empty, disable, fireWith, fire, etc.

(3043,318 3) Deferred: delayed object: Unified asynchronous Management (timer, ajax, script, DOM, and so on need to be managed asynchronously)

(3184,329 5) support: browser function Detection

(3308,365 2) data (): data caching prevents the mounting of elements with large data volumes and prevents Memory leakage.

(3653,379 7) queue (): queue management, team-up, team-out, and execution sequence Management

(3803,429 9) attr () prop () val () addClass () and so on: operations on element attributes

(4300,512 8) on (), trigger (): method related to event operations

(5140,605 7) DOM operation: add, delete, and obtain packaging DOM filtering.

(6058,662 0) css (): style operations

(6621,785 4) serialization operations, data submission, and ajax Methods: ajax () load () getJSON (), etc.

(7855,858 4) animate (): How to implement motion (animation)

(8585,879 2) offset (): Method of position and size

(8804,882 1) jQuery supports modular Mode

(8826) window. jQuery = window. $ = jQuery; The jQuery symbol is abbreviated as $. Mount jQuery to the window, so that jQuery () or $ () can be used to call jQuery directly, otherwise, jQuery cannot be called locally.

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.