jquery源码解析(jQuery源码解析).doc
上传者:蓝天
2022-06-17 14:06:17上传
DOC文件
87 KB
jquery源码解析(jQuery源码解析)
henry 剖析jquery源码
analyzing jquery. 1. 3. 1. js: description
the author yanquan. xu (henry)
the date of 2013 / 5 / 11, 19: 19
establish campus)
由于深爱着javascript语言,而对于业界的框架的层出不穷,我依 然选择了 jquery.并非因为其它框架不好,而是
自然而然的选择和机缘的认识,所以一直用到现在,之后也会说它 的不好. ",因为没有完美的东西.
使用那么长得时间,直到前几天才翻开它的源码看了一下,感触有 一点,怕自己忘记,所以整理了一下,如果不好.
记得告诉我. ”
我下载了 jquery. 1. 3. 1的版本进行阅读,因为所有版本的核心思想
都是一样的,后期更新到现在的1. 9和即将出来的2. 0
的核心都是一样的,只是由于感觉新版本的功能增加得太多,代码 过于偏大不便阅读,所以百度到了 1.3版本的.
开始打开的源码通常都有一些废话在前面,就像下面一样.
/ *.
vl. 3. 2 jquery javascript library.
http: / / jquery. com /
download from http: / / www. codefans, net
john resig copyright (c) 2009
dual licensed under the mit and gpl licenses.
http: / / docs, jquery. com / license
*
date: 2009 / 02 / 19 17: 34: 21 - 0500 (thu, 19 feb 2009)
revision: 6246
/
其实不是废话啦,这是每个公司或者个人的著作信息.这个不说了.
然后代码就以这个开始了()(){
当你把内部全部代码删除掉,其实完整的写法应该是()()()(); 这个就是特别常见的闭包了,其实我第一次 听到闭包还是会觉得生疏的,它的叫法意义类似于命名空间或者一 个类一样,这样更亲切.之所以在这里面写那么多代码.
就是不让里面的世界影响到了外面的世界,因为你的总世界是一个 web页面,而不能因为你写的代码影响到别人的代码,变量
重写了别人的,就是占着别人的位置啦.
然后声明了很多个变量,抽取了一些如下.
var
/ / will speed up references to age, and allows munging its name.
window = this.
/ / will speed up references to undefined, and allows munging its name.
undefined.
//////// map over jquery in case of overwrite
_ jquery = window, jquery.
//////// map over the $in the case of overwrite
$= $window.
jquery = window
henry 剖析jquery源码
analyzing jquery. 1. 3. 1. js: description
the author yanquan. xu (henry)
the date of 2013 / 5 / 11, 19: 19
establish campus)
由于深爱着javascript语言,而对于业界的框架的层出不穷,我依 然选择了 jquery.并非因为其它框架不好,而是
自然而然的选择和机缘的认识,所以一直用到现在,之后也会说它 的不好. ",因为没有完美的东西.
使用那么长得时间,直到前几天才翻开它的源码看了一下,感触有 一点,怕自己忘记,所以整理了一下,如果不好.
记得告诉我. ”
我下载了 jquery. 1. 3. 1的版本进行阅读,因为所有版本的核心思想
都是一样的,后期更新到现在的1. 9和即将出来的2. 0
的核心都是一样的,只是由于感觉新版本的功能增加得太多,代码 过于偏大不便阅读,所以百度到了 1.3版本的.
开始打开的源码通常都有一些废话在前面,就像下面一样.
/ *.
vl. 3. 2 jquery javascript library.
http: / / jquery. com /
download from http: / / www. codefans, net
john resig copyright (c) 2009
dual licensed under the mit and gpl licenses.
http: / / docs, jquery. com / license
*
date: 2009 / 02 / 19 17: 34: 21 - 0500 (thu, 19 feb 2009)
revision: 6246
/
其实不是废话啦,这是每个公司或者个人的著作信息.这个不说了.
然后代码就以这个开始了()(){
当你把内部全部代码删除掉,其实完整的写法应该是()()()(); 这个就是特别常见的闭包了,其实我第一次 听到闭包还是会觉得生疏的,它的叫法意义类似于命名空间或者一 个类一样,这样更亲切.之所以在这里面写那么多代码.
就是不让里面的世界影响到了外面的世界,因为你的总世界是一个 web页面,而不能因为你写的代码影响到别人的代码,变量
重写了别人的,就是占着别人的位置啦.
然后声明了很多个变量,抽取了一些如下.
var
/ / will speed up references to age, and allows munging its name.
window = this.
/ / will speed up references to undefined, and allows munging its name.
undefined.
//////// map over jquery in case of overwrite
_ jquery = window, jquery.
//////// map over the $in the case of overwrite
$= $window.
jquery = window
jquery源码解析(jQuery源码解析)