Forward a previous article on the general framework of jquery suggested reading first
Var
Readylist,
Rootjquery,
core_strundefined = typeof Undefined,
Location = Window.location,
Document = Window.document,
Docelem = Document.documentelement,
_jquery = Window.jquery,
_$ = window.$,
Class2type = {},
Core_deletedids = [],
Core_version = "1.10.2",
Core_concat = Core_deletedids.concat,
Core_push = Core_deletedids.push,
Core_slice = Core_deletedids.slice,
Core_indexof = Core_deletedids.indexof,
core_tostring = class2type.tostring,
Core_hasown = Class2type.hasownproperty,
Core_trim = Core_version.trim,
JQuery = function (selector, context) {
return new JQuery.fn.init (selector, context, rootjquery);
},
Core_pnum =/[+-]? (?:\ d*\.|) \d+ (?: [ee][+-]?\d+|) /.source,
Core_rnotwhite =/\s+/g,
RTrim =/^[\s\ufeff\xa0]+| [\s\ufeff\xa0]+$/g,
rquickexpr =/^ (?: \ s* (<[\w\W]+>) [^>]*|# ([\w-]*)] $/,
Rsingletag =/^< (\w+) \s*\/?> (?: <\/\1>|) $/,
Rvalidchars =/^[\],:{}\s]*$/,
Rvalidbraces =/(?: ^|:|,) (?: \ s*\[) +/g,
Rvalidescape =/\\ (?: ["\\\/bfnrt]|u[\da-fa-f]{4})/g,
Rvalidtokens =/"[^" \\\r\n]* "|true|false|null|-? (?:\ d+\.|) \d+ (?: [ee][+-]?\d+|) /g,
Rmsprefix =/^-ms-/,
Rdashalpha =/-([\da-z])/gi,
Fcamelcase = function (all, letter) {
return Letter.touppercase ();
},
Completed = function (event) {
if (Document.addeventlistener | | event.type = = = "Load" | | document.readystate = = = "complete") {
Detach ();
Jquery.ready ();
}
},
Detach = function () {
if (Document.addeventlistener) {
Document.removeeventlistener ("domcontentloaded", completed, false);
Window.removeeventlistener ("Load", completed, false);
} else {
Document.detachevent ("onReadyStateChange", completed);
Window.detachevent ("onload", completed);
}
};
The above defines a number of function variables and methods (this explanation does not know right)
And jquery is in an anonymous function, using VAR to avoid the use of global variables, the advantage is not to conflict with other libraries or plug-ins
But jquery still has a global variable that is $
which
JQuery = function (selector, context) {
return new JQuery.fn.init (selector, context, rootjquery);
},
The purpose of this code is to build jquery objects, in fact, we return with $ () is an instance of the JQuery.fn.init object,
According to the JS syntax we can see that the prototype of this object points to the prototype of jquery. This enables chained programming operations.
function (window, undefined), the advantage of undefined parameter is to avoid the undefined variable being polluted.
JQuery 1.10.2 Source Analysis Learning 1 (EXT)