jquery source code--General structure

Source: Internet
Author: User

1(function(window, undefined) {2     //constructing a jquery object3     varJQuery = (function() {4       varJQuery =function(Selector, context) {5         return NewJQuery.fn.init (selector, context, RO otjquery);6       }7     returnJQuery;8 })();9 //Tool Method UtilitiesTen //callback Function list callbacks Object One //Asynchronous Queue Deferred Object A //Browser function test support - //Data Cache - //Queues Queue the //Property Manipulation Attributes - //Event System Events - //selector Sizzle - //DOM traversal traversing + //DOM Operation Manipulation - //style manipulation CSS (calculated style, inline style) + //Asynchronous Request Ajax A //animated Effects at //coordinate Offset, size Dimensions -Window.jquery = window.$ =JQuery; -}) (window);

1. Anonymous functions are used to prevent variable contamination.

2. Pass the parameter into the window undefined, on the one hand, after the code compression in the Anonymous function window and undefined can be compressed as parameters, can reduce the amount of code, more importantly, window and undefined as a local variable passed in, You can reduce the access distance of the chain, which means that you can get the window object without having to access the window layer. Undefined parameter passed in is to ensure that the value of undefined is really "undefined", because in some browsers, you can modify the value of undefined, such as undefined = ' test ', window.undefined input is test.


The article is <jquery Technical Insider > Reading notes, http://book.douban.com/subject/25823709/

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.