Imagination is our power

His main point is summarized in this quote:

“Do you really need a 90k JavaScript library (and thats the minified version) to toggle the size of a menu?”

I think his point is valid, and it’s something I’ve seen before in comments, and even from experienced JavaScript developers and bloggers. For example, in an article on SitePoint covering Drag and Drop in HTML5, Alexis Goldstein uses jQuery to demonstrate HTML5′s drag and drop feature. A comment from James Edwards on the post makes a similar point to that of Matt Pass.

I almost responded to James’ commment at the time, and I had written a comment for Matt’s post, but felt this was something I wanted to open up to my larger audience.

Is Library-less Code a Reality Anymore?

Yes, there are small sites built all the time. There are brochure sites, there are one-page info sites, there are microsites — which may not have any, or very little, JavaScript. But those sites are becoming less and less common.

JavaScript libraries are virtually mandatory in websites and web apps today. And sure, it’s nice be able to write things raw like Matt demonstrates in his post. But I feel that in almost all real-world cases, developers will be including at least one major JavaScript library.

So, the problem that Matt points out (i.e. using a sledgehammer to crack a walnut), is actually not a problem at all. In fact, the opposite is true. Because if you are including a library, and you still choose to write lots of raw JavaScript, then you’re probably writing more code than is necessary and are letting the library be a wasted resource.

Yes, in some cases, for performance reasons, even with a library loaded up, you might be better off using raw JavaScript (for example, a simple for loop might be more performant than jQuery’s each() or find() or whatnot). So I’m not completely downvoting the using of raw JavaScript. And that’s besides the fact that oftentimes I just remember the raw version easier than the jQuery version, because that’s how I learned.

But in my opinion, simple code examples that use jQuery code are not overkill at all, but are simply catering to the needs of modern developers — the majority of whom are using jQuery in the very projects where they might be using the simple tutorial code Matt is talking about.

JavaScript is Often Beside the Point

Finally, the other reason I think it’s okay to use jQuery in a post like that is that, well, the point of those posts is often more about principles or concepts, not code architecture, cross-browser issues, or other peripheral matters that would, in my view, distract from the point of the post.

So, although a discussion of some of the extra code used with raw JavaScript might have its benefits, I think it’s better to stay focused on the main point of the post, and not get clouded with other more complicated issues. And if anyone wants to learn raw JavaScript, there are plenty of sources for that.


I will continue to use jQuery even in simple posts that are more focused on CSS3. But maybe there’s something I’m overlooking. Would love to hear anyone’s feedback on this.

Do you prefer that tutorials use jQuery in all cases? Or would you rather see raw JavaScript that can easily be put into a page that doesn’t require any dependencies? Do library-free websites exist anymore?


Comments on: "Why Use jQuery for Simple JavaScript Tutorials?" (1)

  1. Hello friends, how is all, and what you desire to say on the topic of this
    article, in my view its in fact awesome in favor of me.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: