jQuery — An Exploration
To $ or Not To $
I thought I would do a little tooling around on the interwebs to find out more. Is jQuery worth learning? Is it still used in the dev community? A quick Google search starting with “is jQuery…” returned:
According to Wikipedia: “jQuery was originally created in January 2006 at BarCamp NYC by John Resig… designed to simplify HTML DOM tree traversal and manipulation, as well as event handling, CSS animation, and Ajax”
(Note: BarCamp is a series of software developers’ conferences that was created as a response to the more selective/invite-only FooCamp.)
Here is a quick intro to jQuery from w3schools:
The jQuery syntax is tailor-made for selecting HTML elements and performing some action on the element(s).
Basic syntax is: $(selector).action()
- A $ sign to define/access jQuery
- A (selector) to “query (or find)” HTML elements
- A jQuery action() to be performed on the element(s)
- Create a new directory;
- Create a new HTML doc inside this directory;
- Download the one page jQuery library doc/move it into the above directory;
- Add a referential script tag in your HTML doc so you can use the jQuery library (make sure this tag
srcis identical to the name of your jQuery library file);
- Add one more script tag that you will write your jQuery in; and…
- Get to work!
The code above works the same way that the event listener DOM Content Loaded does. I followed the steps as recommended at learn.jquery.com, it was super easy! See below:
There are lots of video tutorials out there to help you get started. I like the short videos posted by LearnCode.academy. After watching a few brief videos, you’ll be able to do much more than just click buttons. You can also animate elements using
fadeIn(), fadeOut(), slideUp(), slideDown(), toggle(), etc. So. Many. Options.
As to whether or not jQuery is still being used, apparently it is! According to w3schools:
jQuery is supported by all current major desktop browsers (Chrome, Edge, Firefox, IE 9+, Safari, Opera) as well as Android and Safari for mobile devices. And have I mentioned that it’s fun and relatively easy to learn??
As to answering the big question of whether or not to learn jQuery, there is no simple answer. As per this very helpful article written by Janeth Kent at ma-no (although they do say that the jQuery trend is on the decline):
JQuery is still in use on a staggering 77 percent of the top 1 million websites, according to BuiltWith. So if you ever find yourself working on such a website, you should know the library. JQuery is a beautiful library apart from popularity. Its methods of chaining are crisp and elegant.
So. If you like to explore and learn, you’ve got nothing to lose. Go for it! Just don’t forget the good old, tried and true Vanilla JS.