JQuery Source Analysis Note _php Tutorial

Source: Internet
Author: User
The purpose of jquery is write less, does more. Its development style of JavaScript is not as strong as Yui, of course, it is not as large as dojo and Yui. It greatly simplifies the daily development of JavaScript, primarily the manipulation of DOM elements (as can be seen from the name query). Another major job is the browser compatibility that every front-end developer needs to face. jquery is compatible with most versions of all major browsers, from the IE6 of evil to modern browsers such as Firefox,chrome. In addition to a small piece of code at the core, the rest of jquery is loosely functional and highly extensible. There are tens of thousands of jquery plugins on http://plugins.jquery.com, and you'll need almost all of the same jquery plugins, and more than one.
The head of the jquery code is the license declaration. The GPLV2 and MIT dual protocols are used. And under the jquery statement is another project statement: Sizzle. This is another open source project for jquery authors, released under MIT, BSD and GPL. It is a standalone selector implementation (Pure-javascript CSS selector engine) that can be used independently. It has a compressed version of only 3KB a little more, known as the most efficient selector implementation. jquery has been using sizzle instead of the original selector implementation since 1.3.
JS Code has a large number of () and {}, here is the use of vim reading, because the% command can quickly find matching parentheses.
Code overall structure and variables
jquery's code is an anonymous function call on the whole:
Copy CodeThe code is as follows:
(Function (window, undefined) {
// ...
}) (window);

This is to avoid polluting the global object and also to manage the execution context easily. This technique is often seen in JS code and is common in jquery code. For example, when jquery and other JS libraries are used simultaneously, the $ symbol may already be in use. In order to still use the $ symbol:
Copy CodeThe code is as follows:
(function ($) {
// $("...")... Use $ as usual
}) (JQuery);

This is where the real jquery object is passed in.
The following goes into the real implementation part, the first is $, which is the declaration of the jquery object, where the most basic two members are listed:
Copy CodeThe code is as follows:
var jQuery = (function () {
var jQuery = function (selector, context) {
The Real initialization function
return new JQuery.fn.init (selector, context, rootjquery);
},
A whole bunch of variable declarations
FN is the primary function implementation point and the starting point for the jquery plugin. It's actually a JS prototype.
Jquery.fn = Jquery.prototype = {
};
A function used by an extension object that dynamically adds a member to the object. After the addition of members to jquery is done with the Extend function.
Jquery.extend = JQuery.fn.extend = function () {
};
// ...
return jQuery;
})();

The jquery object is the core object, all $ (...) All of them are jquery objects, except for the small part directly implemented under JQuery's utility function, most of the functions are added to the jquery object using the Extend method.

http://www.bkjia.com/PHPjc/323478.html www.bkjia.com true http://www.bkjia.com/PHPjc/323478.html techarticle The purpose of jquery is write less, does more. Its development style of JavaScript is not as strong as Yui, of course, it is not as large as dojo and Yui. It greatly simplifies the daily opening of JavaScript ...

  • 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.