To Learn (Or Not Learn) JQuery
Nerval's Lobster writes: jQuery isn't without its controversies, and some developers distrust its use in larger projects because (some say) it ultimately leads to breakage-prone code that's harder to maintain. But given its prevalence, jQuery is probably essential to know, but what are the most important elements to learn in order to become adept-enough at it? Chaining commands, understanding when the document is finished loading (and how to write code that safely accesses elements only after said loading), and learning CSS selectors are all key. The harder part is picking up jQuery's quirks and tricks, of which there are many... but is it worth studying to the point where you know every possible eccentricity?
Like a certain web site.
How can I believe you when you tell me what I don't want to hear?
Most of the Linux kernel is based on jQuery.
This is another in a long chain of articles that seem to assume all developers work on web frontend software. We do not. I have no use for jQuery and thankfully do not have to work on a single line of JavaScript in my day job. Maybe if you want to work on frontend-y stuff then it would be worth learning, but it is by no means required to be a developer.
No matter what they tell you, last Friday's Supreme Court ruling does not say that straight people must accept JQuery.
I'm an American. I love this country and the freedoms that we used to have.
I agree, but there is a balance you should achieve. When I first learned jQuery and realized how easy it was to do a lot of things, I went crazy with it. Nowadays I've realized most of what I was using jQuery for, was better done using minimal jQuery (or none at all) and more CSS. Yes, it would be possible to use plain old javascript, but it's easier to write, AND READ jQuery than it would be to script all browser-specific perks of javascript. At the end of the day, use it, but don't abuse it. It's cached on all client browsers anyway and processing overhead and minimal, might as well use it and save yourself a headache or two.
Same here. Overused it after just starting and now am moving on to a more powerful albeit all encompassing framework (Angularjs specifically). I still use jquery in non-angular projects as a time saving measure when for whatever reason I'm forced to keep hours low; I'm freelance and occasionally have to stick to quotes. But for animation and effects nearly always use CSS3 exclusively, it's hw accelerated and now widely supported enough to rely on. It was and still is a nice pair of training wheels and still has a place in time constrained projects.
Back when I did web stuff a number of years ago, we used jQuery pretty extensively. I've even been involved a bit, submitted performance patches, etc. (none of the code I touched is still present though). Having used other javascript toolkits, jQuery was by far my favorite (I still have nightmares about Dojo). Made a lot of things very easy that were otherwise cumbersome, lengthy, or errorprone to do. Note that when I say jQuery here I mean the core of it, not the UI components and such that came later.
I've actually read the linked articles (*gasp*), and it seems the one referenced to imply that developers distrust it in large projects (really, summary?) is simply elaborating on how they have been using jQuery in a way that doesn't work very well, and found a different way of using it where it does work well. Surprise, jQuery is a tool, and crafting solutions requires you to use the right tool, in the right way, at the right time. Screwdrivers are great for screws, but nails pair better with the hammer.
jQuery is a very helpful tool if you use it right, and I think it would be beneficial for most javascript developers to have played around with it. It's not all that complicated, it's easy to learn, and if you're javascript is novice level, figuring out how/why jQuery works will also improve your javascript skills significantly.
I haven't heard of any other controversy regarding jQuery either but I haven't really been paying attention to it lately. Anyone care to elaborate?
JavaScript guru, you say? Impostor, say I!
Your percentages add up to 100.
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
That's last year. It's been replaced by systemd.
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
To be fair, back in the day browsers were a lot more quirky and getting even simple scripts to work in the big five was a major hassle. These frameworks took a lot of that away. These days, that issue is much less prevalent.
No, it's written using other systemd APIs. It's systemds all the way down...
If you're doing front end web development, at some point, you're going to have to become good at Javascript.
You've got all these different frameworks where everything gets abstracted 3 redirections deep into a pseudo MVC layer populated with promise events and callback system that work well for 80% of the job and make 20% incredibly hard, and STILL in the end ties into the DOM, and is just as breakage prone, all the while explicitly demanding you adhere to their code organization because that way they can encode configuration into class names and function invokations and all of them claiming the other is bad not because of intrinsic issues but because they don't make the same ideological architectural choices like one-page-apps or putting business logic (including navigation!) in pages - even though it's more predicated on popularity than functionality, and ALL of that built on top of the mess that is Javascript and you are well and truly sunk my friend. Not even a run-on-sentence has enough space to cover all the horrible stuff that lies out there for the aspiring web developer.
So I recommend learning Javascript. Once you have a good strong feel for the fundamentals, once you've treated Crockford's "JavaScript: The Good Parts," the same way as you've done with K&R's "The C Programming Language," and you're solid on the basics, THEN jump off into these new worlds of overly pretentious web designers delving into their first languages and claiming you can't write a decent site without coffeescript, haml, and sass. So you can put them in their place, or at least, so you can understand how much they're complicating what is, after all, not that difficult of a thing. Even experienced developers write really, seriously completely awful code with Javascript, thinking they'd doing a decent job because they didn't invest time and energy to understand why they're not.
The only problem is that Javascript is bad. I like learning by examples, but that is so not the way to go with Javascript. Examples abound - but they're more than likely to be bad examples. There's reference books, like "Javascript: The Definitive Guide," but they're not great for learning. So what I do is tell people to learn jQuery first.
With jQuery and a few minutes, they can pick up the basics. Someone who already knows CSS or writes code for a living should feel productive in less than a full work day. It's easy, it's fast*, it handles browser differences**, there are well documented examples of how to use each feature on the jQuery doc pages, and best of all for me - it's non intrusive, so you can fit in the new vanilla javascript you're slowly picking up in, without needing to learn any framework specific configurations or magic function naming or guessing why it's not calling a method because it's not been added to the object prototype by your pesudo controller registration.
For me, I hate frameworks that are all-or-one solutions. Big heavyweight*** frameworks that tell you "This webpage is now a ____ application". First, they never are perfect solutions, and second, they always make some percent easier at the cost of making the rest painful. I think when learning a new language, especially if you've already got one or more under your belt, forcing someone to do it your way, or making familiar patterns or constructs hard is a huge detriment. Besides, how can you expect someone to learn if they're not allowed to get it wrong? You end up with folks who don't understand the importance of things like memory management if they never had to do it, and how useful are they during crunch mode?
So, yeah. Learn jQuery. Learn dom traversal and manipulation. Learn event registration. Learn AJAX. Try out some animations. Write a plugin or two. Many of these things are appearing in modern browsers now, but once you understand the concept, the basics that are endemic to web development, and you can be productive, then you'll have the grace time needed to properly learn actual Javascript. Then you get out your
And he did it in assembly, on an Atari 800, blindfolded, in the dark, in a cage full of venomous snakes and sharks.
Just cruising through this digital world at 33 1/3 rpm...
Agreed. The site does do an unfair comparison, leaving out all of the benefits of something like jQuery. I've done plenty of projects where jquery sped things up and made it easy to manage. Doing them in native JavaScript would have been a nightmare and wasted a ton of time.
Just cruising through this digital world at 33 1/3 rpm...
If you are working on an existing project that has already chosen to use jQuery, then you should learn it.
Otherwise, I wouldn't bother. Just learn Vanilla JS, and skip jQuery. Your pages will be faster and better.
jQuery was a useful thing a few years ago, but now that browser standards compliance is so much better it's a big chunk of unnecessary code.
GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
In my perception jQuery has basically become the JavaScript standard library.
Basically any combination of frontend toolkits has it included somewhere, so you don't even have to worry about doing that. It's the default for Joomla and Wordpress and there are a measurable amount of functions that take care of the gruntwork and normalize utility across browsers.
On top of that, the amount of JS projects relying on jQuery as a foundation is staggering. The secondary market has tools built around the jQuery ecosystem and the project as a whole does an excellent job at marketing and advocating.
I personally see the next generation in such avantgarde stuff as Googles Polymer (pretty amazing) but until everyone has moved to SPAs and web components - which is not happening any time soon - but until then it's not the worst idea to familiarize yourself with the concepts and the utility funcitons of jQuery. ... *After* you've learned JS itself properly, that is.
My 2 cents.
We suffer more in our imagination than in reality. - Seneca
There is a performance aspect to consider, however, especially on mobile where the network sucks. It's very likely that people would already have the CDN version in their browser cache since a lot of website use that link. By forcing users to download your version, you are slowing things down for them at the worst possible time - their first visit to your website.
If you have valuable content and a captive audience, fine, but if like most people you are in dire need to attract and retain visitors, it's best to put chances of doing a first good impression on your side. Use the google hosted version and keep an eye on things.
lucm, indeed.