TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

John Resig annotates original jQuery source code

523 点作者 tomlemon大约 10 年前

24 条评论

cryptoz大约 10 年前
Very neat content, but does it have to be formatted like this? I respect that it preserves the original file, but it makes it very difficult to read. Comments added to the source code would serve much better for the purposes of understanding the code.<p>This tool makes it impossible to read the annotation and the source code at the same time. Clicking on &#x27;set&#x27; for example, about 20-30 lines in, lets you read the annotation, but not the function. You have to hide the annotation to read the code.<p>Wouldn&#x27;t inline&#x2F;multiline comments be so much better than this?<p>Edit: Citation&#x2F;example: <a href="http:&#x2F;&#x2F;i.imgur.com&#x2F;CHOFGML.png" rel="nofollow">http:&#x2F;&#x2F;i.imgur.com&#x2F;CHOFGML.png</a>
评论 #9336610 未加载
评论 #9336496 未加载
评论 #9336858 未加载
评论 #9336576 未加载
评论 #9337069 未加载
评论 #9336627 未加载
评论 #9336600 未加载
评论 #9337167 未加载
评论 #9336479 未加载
Stratoscope大约 10 年前
It&#x27;s very kind of John to mention my first jQuery plugin in the notes.<p>Unfortunately, it was not a very good plugin and probably set a bad precedent.<p>Like so many new jQuery developers, I went &quot;Chaining? Whoa. Chain all the things!&quot;<p>So I attached the plugin to $.fn, not thinking about the fact that what the plugin did had very little to do with the current element selection.<p>I may have been the first to make this mistake, but at least I wasn&#x27;t the last. :-)<p>Perhaps I redeemed myself by coming up with the idea to use $.prototype for plugin methods instead of copying the method references by looping through $.fn (we kept $.fn as an alias of $.prototype for compatibility). So a $(...) call became a lot faster.
评论 #9339085 未加载
nothrabannosir大约 10 年前
What surprises me is the lack of comments in the original file. This leads to e.g.:<p><pre><code> this._get(i).$$tmpFunc = f; this._get(i).$$tmpFunc(i); this._get(i).$$tmpFunc = null; </code></pre> with the comment (from now):<p><i>So this may look crazy — it certainly does to me! Why not just do: f.call(this._get(i))? If I remember correctly, and I just did some double-checking and I think this is the case, but IE 5 didn’t support .call()! The original version of jQuery event worked back to IE 5… I can hardly believe. </i><p>I personally hate coming across snippets of code like this (usually from myself ): ). What do I do here? Can I just replace this with .call? Why did he not do .call? Performance? Or just MSIE5 (if I ever figure that out in the first place).<p>All my respect to mr. Resig, of course! What an almost legendary piece of software. Just interesting to see that this commentless programming is something of all pedigrees.<p>And a note to people saying &quot;learn from this,&quot; please also learn that without the original author and rapgenius, we would never have understood that part. Or at least I wouldn&#x27;t.
评论 #9337831 未加载
评论 #9337728 未加载
danso大约 10 年前
The annotations are also a great reminder of how programming used to be not so long ago. It&#x27;s hard to imagine having to search Internet Archive for your own source code in this age of Github:<p><a href="http:&#x2F;&#x2F;genius.com&#x2F;5088475" rel="nofollow">http:&#x2F;&#x2F;genius.com&#x2F;5088475</a><p>&gt; Note: This may not be the first first code released, but it appears to be the earliest copy that we’ve found, so far. This is a copy that was indexed by the Internet Archive on Feb 3rd 2006, so about 2.5 weeks after the initial release. It’s very likely that a few things changed in that time period and I’ll try to make a note of some of those, that I can remember, inline.
alelefant大约 10 年前
I&#x27;m sorry, but this has to be said. This guy loves exclamation points! Almost every paragraph features one. It reminds me of a great Seinfeld episode:<p>Jake: Well, maybe I don&#x27;t use my exclamation points as haphazardly as you do.<p>Elaine: You don&#x27;t think that someone having a baby warrants an exclamation point.<p>Jake: Hey, I just chalked down the message. I didn&#x27;t know I was required to capture the mood of each caller.<p>Elaine: I just thought you would be a little more excited about a friend of mine having a baby.<p>Jake: Ok, I&#x27;m excited. I just don&#x27;t happen to like exclamation points.
评论 #9338151 未加载
tomlemon大约 10 年前
John also spoke at the March Code Genius. You can check out his full talk here: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=H4sSldXv_S4" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=H4sSldXv_S4</a>
IgorPartola大约 10 年前
Anyone else already find the XSS in genius.it?<p>Edit: wow, the whole thing is seriously broken. Emailing them now.<p>Edit 2: It&#x27;s not as broken as I thought, and these guys are quick to reply and try to figure things out. To be clear, I haven&#x27;t gotten it to run arbitrary JS, just include arbitrary HTML, which isn&#x27;t as dangerous.
评论 #9336814 未加载
评论 #9338084 未加载
评论 #9337715 未加载
pearjuice大约 10 年前
Though Resig&#x27;s anecdotes are fun and interesting to read, it doesn&#x27;t help that much with understanding the actual source code. Here&#x27;s a better version in terms of readability and depth:<p><a href="https:&#x2F;&#x2F;robflaherty.github.io&#x2F;jquery-annotated-source&#x2F;" rel="nofollow">https:&#x2F;&#x2F;robflaherty.github.io&#x2F;jquery-annotated-source&#x2F;</a><p><a href="https:&#x2F;&#x2F;robflaherty.github.io&#x2F;jquery-annotated-source&#x2F;docs&#x2F;01-core.html" rel="nofollow">https:&#x2F;&#x2F;robflaherty.github.io&#x2F;jquery-annotated-source&#x2F;docs&#x2F;0...</a><p>Sadly, no longer updated since jQuery 1.6.2 which was released in 2011.
评论 #9337327 未加载
评论 #9337021 未加载
buzzkills大约 10 年前
Wow, makes me feel a little better that he had 75 open source projects before he had a &#x27;hit&#x27;. :)
评论 #9337698 未加载
Vekz大约 10 年前
Maybe I missed the release announcement on this genius.it thing but thats the real story<p><a href="http:&#x2F;&#x2F;genius.it&#x2F;https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9336297" rel="nofollow">http:&#x2F;&#x2F;genius.it&#x2F;https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=933629...</a>
Zelphyr大约 10 年前
If you&#x27;re a new or relatively new developer I highly recommend reading through things like this. All too often developers get in the habit of writing a lot of code without also reading what other more experienced developers have written.
pdevr大约 10 年前
Amazing that it has been more than nine years since the original release (Jan 14, 2006)!<p>How long did it take for John to write this initial version? Any idea?
评论 #9336971 未加载
gcb0大约 10 年前
on mobile: i only see the code. sigh. why even serve me a different page? I&#x27;m running full blown Firefox.
stevebot大约 10 年前
So glad jQuery came along and became what it is. Scary to think of a world where it was just bundled alongside Prototype. For those not versed in Prototype, those were dark days (at least for me).
评论 #9337850 未加载
golergka大约 10 年前
Is there a list of other source code annotations on Genius? Their &quot;tech&quot; section of the web site is full of crappy startup news and doesn&#x27;t even link to this gem.
seanalltogether大约 10 年前
<p><pre><code> if ( !b ) for ( var j in a ) this.style[j] = a[j]; else this.style[a] = b; </code></pre> <i>I really dis-liked having unnecessary braces. This… unfortunate… style preference plagued us for quite a while and caused all sorts of avoidable logic errors.</i><p>I really wish this kind of coding was removed completely from some languages.
staunch大约 10 年前
I found myself wishing this was a screencast.
评论 #9336652 未加载
swavaldez大约 10 年前
Anyone knows if there are outdated sites that still using early versions of jQuery? =))
评论 #9337889 未加载
daniellmb大约 10 年前
I&#x27;ve archived the original 2005 jquery script (aka jselect) <a href="https:&#x2F;&#x2F;github.com&#x2F;daniellmb&#x2F;jquery-archive" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;daniellmb&#x2F;jquery-archive</a>
yukinon大约 10 年前
Firefox 36, OS X. This doesn&#x27;t seem to be working for me at all.
wehadfun大约 10 年前
I would actually like this in an IDE. Visual Studio kind of does this with header comments but it would be great to be able to show&#x2F;hide comments with links, rich text,...
评论 #9336844 未加载
评论 #9337462 未加载
igravious大约 10 年前
What&#x27;s the standard the Genius uses to perform annotations? Anybody know?
ggamecrazy大约 10 年前
It&#x27;s 500&#x27;ing for me, anyone else seeing this?
curiously大约 10 年前
would love to see a frontend framework that uses jQuery syntaxes only.