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 'set' 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't inline/multiline comments be so much better than this?<p>Edit: Citation/example: <a href="http://i.imgur.com/CHOFGML.png" rel="nofollow">http://i.imgur.com/CHOFGML.png</a>
It'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 "Chaining? Whoa. Chain all the things!"<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'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.
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 "learn from this," please also learn that without the original author and rapgenius, we would never have understood that part. Or at least I wouldn't.
The annotations are also a great reminder of how programming used to be not so long ago. It's hard to imagine having to search Internet Archive for your own source code in this age of Github:<p><a href="http://genius.com/5088475" rel="nofollow">http://genius.com/5088475</a><p>> 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.
I'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't use my exclamation points as haphazardly as you do.<p>Elaine: You don't think that someone having a baby warrants an exclamation point.<p>Jake: Hey, I just chalked down the message. I didn'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'm excited. I just don't happen to like exclamation points.
John also spoke at the March Code Genius. You can check out his full talk here: <a href="https://www.youtube.com/watch?v=H4sSldXv_S4" rel="nofollow">https://www.youtube.com/watch?v=H4sSldXv_S4</a>
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'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't gotten it to run arbitrary JS, just include arbitrary HTML, which isn't as dangerous.
Though Resig's anecdotes are fun and interesting to read, it doesn't help that much with understanding the actual source code. Here's a better version in terms of readability and depth:<p><a href="https://robflaherty.github.io/jquery-annotated-source/" rel="nofollow">https://robflaherty.github.io/jquery-annotated-source/</a><p><a href="https://robflaherty.github.io/jquery-annotated-source/docs/01-core.html" rel="nofollow">https://robflaherty.github.io/jquery-annotated-source/docs/0...</a><p>Sadly, no longer updated since jQuery 1.6.2 which was released in 2011.
Maybe I missed the release announcement on this genius.it thing but thats the real story<p><a href="http://genius.it/https://news.ycombinator.com/item?id=9336297" rel="nofollow">http://genius.it/https://news.ycombinator.com/item?id=933629...</a>
If you'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.
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?
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).
Is there a list of other source code annotations on Genius? Their "tech" section of the web site is full of crappy startup news and doesn't even link to this gem.
<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.
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/hide comments with links, rich text,...