Why Use jQuery for Simple JavaScript Tutorials?



A trackback on one of my previous posts (yeah, trackbacks aren’t just for spam) alerted me to an interesting point brought up by a blogger named Matt Pass . In his post entitled Walnut, Meet jQuery Sledgehammer he politely explains why he feels it’s overkill to use jQuery in a simple tutorial post.

A trackback on one of my previous posts (yeah, trackbacks aren’t just for spam) alerted me to an interesting point brought up by a blogger named Matt Pass. In his post entitled Walnut, Meet jQuery Sledgehammer he politely explains why he feels it’s overkill to use jQuery in a simple tutorial post.

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.

Thoughts?

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?

 in Why Use jQuery for Simple JavaScript Tutorials?

Related posts:

  1. Getting Buggy CSS Selectors to Work Cross-Browser via jQuery
  2. Recreating the MLB.com Content Switcher with jQuery and CSS3
  3. How to Do Absolutely Everything Ever in jQuery, CSS3, & HTML5

 in Why Use jQuery for Simple JavaScript Tutorials?

 in Why Use jQuery for Simple JavaScript Tutorials?

 in Why Use jQuery for Simple JavaScript Tutorials?  in Why Use jQuery for Simple JavaScript Tutorials?

 in Why Use jQuery for Simple JavaScript Tutorials?
Artica Source: Why Use jQuery for Simple JavaScript Tutorials?



angry birds rio | super mario world | juegos de futbol | angry birds online | disney channel games | crafts for kids | handmade gifts | handmade jewelry
Free WordPress Themes
freshlife WordPress Themes Theme Junkie