1.1 self-called anonymous functions:
(Function (window, undefined) {// jquery code}) (window );
This is a self-called anonymous function. The first bracket is an anonymous function, the second bracket is executed immediately, and the input parameter is window.
1. Why does a self-called anonymous function exist?
By defining an anonymous function, a "private" space is created. jQuery must ensure that the created variable cannot conflict with the program that imports it.
2. Why input a window?
The input window changes the window from a global variable to a local variable. When jQuery accesses the window, it does not need to return to the top-level scope to allow faster access to the window. More importantly, it can be optimized when the code is compressed.
3. Why does undefined exist?
Within the scope of self-called anonymous functions, make sure that undefined is really undefined. Because undefined can be rewritten.
1.2 overall architecture:
(Function (window, undefined) {// construct the jQuery object var jQuery = function (selector, context) {return new jQuery. fn. init (selector, context, rootjQuery );} // tool function Utilities // asynchronous queue Deferred // browser test Support // Data cache Data // queue // Attribute operation Attribute // Event processing // selector Sizzle // DOM traversal // DOM operation // CSS operation // asynchronous request Ajax // animated FX // coordinate and size window. jQuery = window. $ = jQuery;}) (window );