The Use of jQuery in Tutorials
I Write What I Do
This blog is a reflection of things that I learn. I use jQuery a bunch. So when I translate things into a tutorial, I do it how I would do it.
I have only worked on a handful of sites that didn’t use jQuery in the last many years, and those that didn’t used some other library or just didn’t need JavaScript at all.
jQuery is JavaScript
Literally. Using jQuery is still literally writing and working with JavaScript directly. jQuery just makes it easier and lowers the bar to entry. I know loads of good JavaScript developers who started with jQuery. Just like there are loads of good guitar players who started as a Dave Matthews Band Cover Band Cover Band.
Tutorials are Concepts
The goal of a tutorial is to teach an idea and do it fairly succinctly.
Let’s say you wanted to select a button with a certain class name and change some text when it is clicked. To avoid any dependancies, maybe you dodocument.querySelectorAll(".my-button")
. But that will return an array so you need to use [0] at the end of it to target the element and attach the event. Or should we just use querySelector
instead which selects the first? Or should we run a loop or map over the array to bind to all of them? Or should we have usedgetElementByClassName
? What about browser support? Should we talk about polyfills for that? Or should we just add an ID and use getElementById
since that’s likely a best practice?
Or, we could just do $(".my-button")
and get on with the tutorial. All of that stuff is interesting and worthy of discussion, but not in every single tutorial every single time. jQuery allows the concepts in tutorials to shine without getting bogged down in detail.
The Future
Right now I feel like jQuery is still a pretty important part of the front end stack, well worth learning, and still appropriate to use in tutorials.
But things will change on the web. How JavaScript is presented in tutorials will change as well. Probably. We’ll change with it. Probably. I’ve seen comments floating around the last few months like “I feel like if I’m using jQuery I did it wrong.” which I’ve never heard before and may be harbingers of change. The newschool approaches of Ember/Angular also loom.