jQuery.min.js是一個(gè)非常流行的Javascript庫(kù),它幫助我們通過(guò)更少的代碼完成更多的工作。下面是jQuery.min.js的完整代碼:
/*! * jQuery JavaScript Library v3.6.0 * https://jquery.com/ * * Includes Sizzle.js * https://sizzlejs.com/ * * Copyright jQuery Foundation and other contributors * Released under the MIT license * https://jquery.org/license * * Date: 2021-03-02T17:10Z */ ( function( global, factory ) { "use strict"; if ( typeof module === "object" && typeof module.exports === "object" ) { // For CommonJS and CommonJS-like environments where a proper `window` // is present, execute the factory and get jQuery. // For environments that do not have a `window` with a `document` // (such as Node.js), expose a factory as module.exports. // This accentuates the need for the creation of a real `window`. // e.g. var jQuery = require("jquery")(window); // See ticket #14549 for more info. module.exports = global.document ? factory( global, true ) : function( w ) { if ( !w.document ) { throw new Error( "jQuery requires a window with a document" ); } return factory( w ); }; } else { factory( global ); } } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { "use strict"; var arr = []; var document = window.document; var getProto = Object.getPrototypeOf; var slice = arr.slice; var concat = arr.concat; var push = arr.push; var indexOf = arr.indexOf; var class2type = {}; var toString = class2type.toString; var hasOwn = class2type.hasOwnProperty; var fnToString = hasOwn.toString; var ObjectFunctionString = fnToString.call( Object ); var support = {}; var isFunction = function isFunction( obj ) { // Support: Chrome<=57, Firefox<=52 // In some browsers, typeof returns "function" for HTML
這里的代碼使用到了一些Javascript的高級(jí)特性,使用了函數(shù)嵌套、立即調(diào)用函數(shù)表達(dá)式、自執(zhí)行函數(shù)等語(yǔ)法。雖然代碼比較復(fù)雜,但它是jQuery這個(gè)流行Javascript庫(kù)的核心,沒(méi)有它,我們很難在Javascript應(yīng)用中使用jQuery提供的方便方法。