Skip to content

Instantly share code, notes, and snippets.

@dmethvin
Created February 18, 2015 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmethvin/766de2d37c163e5ec6d5 to your computer and use it in GitHub Desktop.
Save dmethvin/766de2d37c163e5ec6d5 to your computer and use it in GitHub Desktop.
Reply from John Resig
From: John Resig [mailto:jeresig@gmail.com]
Sent: Sunday, February 26, 2006 7:55 PM
To: Dave Methvin
Subject: Re: jQuery suggestions
> JQuery is incredibly useful. I just started playing with it yesterday
> and already I'm hooked. I know exactly *why* I like it so much too.
> Have you ever read Paul Graham's essay "Succinctness is Power"?
> http://www.paulgraham.com/power.html
> Read it, and your neck will be sore afterwards. That's what happens
> when you nod your head up and down so much in agreement.
Thanks Dave - glad you enjoy it. I've never read that essay of his, per se,
but after doing a quick read I can definitely see what you mean. Succinctness
is huge for me, it just rubs me wrong everytime a new monster Javascript library
comes out - the features are great, but who can stand using them?
> In using jQuery.js I've found a couple of things I wanted to point
> out. The most important is a namespace conflict; $._Select promotes
> input types to appear as first-class tags. Unfortunately, there is an
> <input type=button> as well as a <button> tag; $("button") will
> retrieve the former but not the latter. There are workarounds, but it
> seems wrong that $("button") doesn't get <button>. Also, if the
> context is an XML document, such as one from AJAX, XML tags with these
> names will be inaccessable using the direct tag name. Instead of
> silently promoting input types into the namespace, perhaps there should
> be some special shorthand syntax to retrieve them.
Hmm, yeah - I definitely see what you mean. I'll flag this email and make 'button'
a fringe case. Also, I will not do any of those sanity optimizations unless
you're working within an HTML Document, which is just the right thing to do.
> Just a couple of other observations from looking at the code--which by
> the way, is much easier to understand IMO than Prototype:
>
> Is $c ever used? I didn't see any references.
That was introduced just the other day, in fact, I think I managed
to break something when I started using it.
> In method css(), "!b" should be "b != null" just the way it is in
> set() a few lines above. Otherwise you won't be able to set any CSS
> attributes to an empty string or zero.
Noted, will fix.
> Instead of using this in addClass() and toggleClass():
>
> this.className += ( this.className.length > 0 ? " " : "" ) + c;
>
> Consider using this:
>
> this.className += ( this.className && " " ) + c;
>
> There aren't a lot of common opportunities for short-circuit &&
> (although I saw you had one in $.attr--looked like a Prototype
> workaround). It does shorten the code though, and makes you look like
> like a Javascript guru. I benchmarked them and the new code may
> actually be a (trivial) bit faster.
Yeah, I've been working may way through doing short-circuiting wherever
possible - there's obviously still a lot of cases where it can be done.
Someday jQuery will be completely pure and optimized - but it's
not quite there yet. ;-)
> I only saw a few other trivial things that tripped me up a bit. The
> $.hasWord is more like $.hasClass, and$.cleanSpaces seemed like it
> should be $.trimSpaces instead. The indentation also was inconsistent
> in a few of the functions, but that may be due to differences in the
> editor tab settings (I use 4 spaces per tab and it looks like you may use 2).
Yeah, again, some good points. Some of that wording is legacy from older
versions of jQuery. Also, my editor hates me, gotta fix that.
> Again, thanks for thinking up such a great--er, SUCCINCT!--way to
> express common DOM programming tasks.
Thanks! I'm working on jQuery everyday now, so be sure to watch for more
releases coming up soon. I have a whole slew of helper functions planned
that will make things even saner, I hope.
Talk to you soon, I'll let you know when I get those bugs fixed.
--John
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment