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?
It's awesome, and a lot easier than learning all of the eccentricities of plain old JavaScript.
So if I work on, say, Linux kernel issues, it is essential for me to know about jQuery?
Like a certain web site.
How can I believe you when you tell me what I don't want to hear?
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.
Just one Greek?
Well, that's good to know, for a while there we were worried that the entire country of Greece was going to collapse. That would have been quite a crisis!
You could be learning already. It's free! Nothing is stopping you.
Share this post! The link labelled "Share" is there for a reason ya know!
Do NOT use a hosted library. If you have to use it, copy the damn thing to your own server.
Hosted libraries, especially massively used ones like jQuery, are a security disaster waiting to happen.
Not to mention the privacy issues caused by using a library hosted by a company that is known to correlate every bit of information about people that they can get their hands on (Google)
I don't know about other toolkits, but Angular uses it for a number of tasks. There's a lightweight clone, but plugging in jQuery to replace that is very common. I've used jQuery with ExtJS as well because Ext's equivalent was pretty bad (as of 3.X and 4.X) for doing straight forward DOM access. Learn the very basics of querying the DOM with it and adding new elements, then move on.
Front end browser development is littered with dozens of front end frame works that have fizzled over the years. YUI, Prototype, script. aculo.us, etc. All popular in their day. jQuery is still active but certainly on the decline.
You want to be a good front end developer? Learn about the DOM model. Learn about HTTP, HTTP/2 and CSS. Learn the fundamentals of how all that stuff works together and then you'll never need to worry about picking up whatever front end framework is used by the cool kids.
ASP supported JavaScript back in 1999.
Netscape Enterprise also supported server side JavaScript. IIRC is may have needed a plug-in.
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?
Anyone who is considering learning jQuery should also check out Vanilla JS.
"We mustn't be caught by surprise by our own advancing technology" -- Aldous Huxley
Just look it up whenever you need something. Separating learning and using is such an outdated concept.
If you need to perform complex DOM manipulation jQuery is still the best tool, fortunately recent javascript frameworks drastically reduced the need for manual DOM manipulation. Usually you encapsulate your jQuery DOM manipulation code using your framework of choice, this is very common when doing specialized UI components.
I personally don't like jQuery for various reasons, but if one is going to use it, learn the why's and how's, so that when things aren't working, you can figure out why.
Myself, I use ExtJS heavily for projects on the front end, granted i'm doing things that actually have a purpose for business.
http://vanilla-js.com/ is probably much more worth learning and using. The *ONLY* reason to be using jQuery is for IE8 support, but I've long since required IE9+ for all freelance work I do, and do everything in CSS and Vanilla JS now.
Morphing Software
Anyone who is considering learning jQuery should also check out Vanilla JS.
I love it every time "Vanilla JS" is brought up in a jquery post. Please see my previous post on the topic, which demonstrates why that website is both dishonest in its comparison, as well as a perfect example of why you should use a proven library instead of reinventing the wheel (and all the bugs that come with said reinvention)
http://slashdot.org/comments.p...
Really? A big decision to learn a library? I learned jQuery in like a week and wrote a full mobile app in 3 weeks that used it. It was ok. It was kinda better than plain javascript, but only sometimes. It's a freaking web hack script language. There are a zillion of them, all equally kinda useful, kinda useless, full of crappy tricks you learn as you need to. It's no big deal, you don't even have to know how a computer works to get an app running. So sure, why not learn it. It doesn't take long, and it's kinda useful if you really have to write another broken web app. /shrug
Because today someone will say Angular is the way to go. Tomorrow they will say something different. Web development is a big joke.
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
Who the hell still uses Javascript (library or not) to fade things in/out? Use CSS, damnit.
Get free satoshi (Bitcoin) and Dogecoins
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...
Stop! Just stop already! Nobody gives a shit about Dice's clickbait fluff pieces void of content. We know you need to justify Dice's executive management's $1M salaries (http://finance.yahoo.com/q/pr?s=DHX+Profile) but this is getting ridiculous and you are alienating your most loyal users.
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
jQuery isn't without its controversies
Huh?
and some developers distrust its use in larger projects because (some say) it ultimately leads to breakage-prone code that's harder to maintain.
This article is less critical of jQuery than the summary led me to believe. It just warns you against two things: (1) a long procedure of code for the ready argument, "The Big Main Method Problem," and (2) DOM-centric code. But neither of these are problems, and neither of them are caused or even encouraged by jQuery.
After the click-baitish FUD, the summary goes on, saying you might as well use it anyway:
But given its prevalence, jQuery is probably essential to know
The phrase "probably essential" is a weird combination of a weak and a strong word, and may be a sign of a writer who is half asleep.
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?
Who cares? The jQuery reference is easy to browse for whatever you need right now, and there's little need to understand one part of jQuery to use another.
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
How about people who need to support browsers other than the latest and greatest? I'd love to tell everyone to upgrade. Unfortunately, with corporate intranets you are sometimes forced to support whatever your entire company is using.
How about people who need to support browsers other than the latest and greatest?
Does <blink> still work in your organization? What about <center>? You lucky dog.
lucm, indeed.
I was going to comment on the jQuery Big Main Method problem, and how it is only a problem if you let it be a problem. But because slashdot is being a little fucking bitch about curly-braces, instead I'm going to just say FUCK YOU AND YOUR HATRED OF CURLY-BRACES SLASHDOT!!!
"some developers distrust its use in larger projects because (some say) it ultimately leads to breakage-prone code that's harder to maintain."
Most likely because they write shit bloated code in the first place.
Meanwhile, jQuery + SQLite + MariaDB connector, I've got my own personal intelligent porn recommendation/scraper/indexer site that runs through a few million images and renders my requested search results in under a tenth of a second.
So odds are, it's those developers talking about breakage-prone code that are the crap devs, anyways.
Still waiting on Serviscope_minor to wake up to fucking reality and realize that Jessica Price isn't going to fuck him.
technology has moved on; jQuery is yesterday's solution;
Or just stick to real programming languages, without jumping on the bandwagon.
You are aware that vanilla-js is a joke site, right?
18 year JS programmer here. Learn JavaScript proper (well) first, then a framework such as Angular.
I think it's pretty clear that this means, given you need to write JavaScript for the browser, should you learn jQuery and if so how? The fact that accountants and plumbers don't really need to know jQuery is kind of a given, right?
Democracy Now! - your daily, uncensored, corporate-free
It helps some times, and if you are going to become a good JavaScripter, how much of the effort is really redundant? You'll probably need to learn how to select an element with CSS selectors even if you don't use jQuery. It's clear you eventually won't need jQuery for this, but a) jQuery is a little less verbose b) learning how to use selectors is 90% of learning jQuery.
Granted, you don't need to learn how to write a jQuery plugin anymore, not that would be difficult to learn anyway. Aside from that, what is there? Using plugins: trivial. Using the jQuery's ajax stuff: trivial. Learning to use promises: you need that anyway, learning jQuery's slight differences isn't really a big deal.
Democracy Now! - your daily, uncensored, corporate-free
You are aware you could actually click on that link in my post, right? If you did, you'd have your answer.
jQuery was relevant as a shim for browser compatibility 10 years ago - and even then only for AJAX. Modern browser's DOM API is far more powerful than what pathetic methods jQuery offers. And what jQuery does offer is often broken, deprecated or just shit code. Want to animate something the way the web animated things in the 90's? Use jQuery. Want to use native animation methods that are orders of magnitude more efficient, more featureful and MUCH easier to use? Use the fucking DOM API that comes with the god damn browser that jQuery is hiding from you. document.querySelector is a thing now! Need to do advanced event handling by manipulating the bubble/capture phase? jQuery can't do that. Are their binding selectors like fucking special or something? No, they just never did that and fuck you if you think you need to change the phase that your event fires at. And don't even get me started on the AJAX bullcrap - undocumented "features", suddenly deprecated properties without any documentation or reason why they changed, properties that make no sense: dataType for content-type? type for method? You do know that HTTP existed and had names for these things before you came along, right? Oh but you added "method" also, so "type" and "method" are the same but "content-type" is "dataType" - SERIOUSLY?! WHAT THE FUCK!? This is what all code would look like if the nazis had won the war. And the author! Riseg writes a book, called something like "advanced javascript techniques" and puts fucking syntax errors in it!! Not to mention it reads like "ah duh, I don't know what JS is, ah duh" Then the second book "secrets of the JS ninja" is actually a really good book, it has his name on it, but it also has someone else's name on it this time. So my guess is it went like this "John, you suck, but your shit is popular, can we have this other guy write a book and put your name on it and give you some money?"
/s - oh wait! It probably executes 1 lines of code "if (document.querySelector) { return document.querySelector(e); }" Woooohhhhh JQUERY MAGIC!!!
And that's just how jQuery has done me wrong. The real reason I hate it is how it continuously cripples programmers by teaching them idiotic programming patterns that should never have existed in the first place. You don't write a 2000 line application with CHAINING CONSTANTLY. Ever hear of a variable?! Do you think it might be better to use them instead of constantly abusing the queryselector? Do you think CPU cycles are free!? "OH HEY! IT CACHES THO!" Yeah, I'll bet it does it better than the native selector
I think jQuery should be remembered as the lib that broke the internet. jQuery is the first lib that became so popular that the RFC process was aborted and now Risig makes up some idiotic shit on his own and we call it "standard" because of the logical fallacy "appeal to popularity". Just because a lot of people like it does not make it correct. Actually, given the average skill of web programmers I would say popularity should work against it.
I'm going to spend the next several years of my life trying to undo the damage jQuery has done to the systems that I work with. And the damage is mostly human damage - that is, programmers that can no longer program web because of the things jQuery taught them. And god help the next candidate that comes in for an interview that writes "Languages Known: Java, JavaScript, C#, jQuery". JQUERY ISN'T A FUCKING LANGUAGE! Everything jQuery can do DOM API can do better, easier, with less code and everyone that can read JS can understand it. Learn DOM API - throw jQuery in the trash where it belongs.
In conclusion it's a Swiss-army-penknife for the browser. You can play with it or carry it around at all times ready to whip out. Some here like to disparage jQuery, but the only case for specifically not using it is as a dependency for some library.
FYI, check this page source code. You'll find some jQuery code. It's funny how some articles here seem being related to Slashdot's tech...
This should-I-use-X-library BS is getting old. Some have touched on this tangentially with their replies, but if you learn JavaScript itself, then learning and using any random library written in it will be easy. So, learn JavaScript not the latest catchy library and then your indecision on which library to learn and use becomes moot.
A more serious answer:
If you are seeking employment by a company as a kernel developer, and you want to publish your portfolio on a website in order to get HR to consider you, you might need some scripts on that site.
Who the hell still uses Javascript (library or not) to fade things in/out? Use CSS, damnit.
You still need the script to insert the class that triggers the CSS fade or size transition. You also need the script to work around the fact that CSS cannot transition to or from height: auto .
How about "compatible with browsers that still receive security updates when needed"? Windows XP is the last desktop Windows operating system that can't upgrade past IE 8, and it's been unsupported for over a year. Windows Vista has IE 9, and Windows 7 has IE 11.
Personally, I find jQuery great as the baseline to support bespoke programming solutions.
There is a LOT of love for framework over libraries like jQuery, but in my experience most hit up against Dietzler's Law* pretty hard. with frameworks one has to be rock solid in the real browsers stuff AND the framework one chose AND the hacks you had to set up to meet the gap between requirements and the framework sweetspot. (vs bespoke, where it's just the real browser stuff and then straight to the gap ;-)
*Dietzler's Law: "Every Access project will eventually fail because, while 80% of what the user wants is fast and easy to create, and the next 10% is possible with difficulty, ultimately the last 10% is impossible because you can’t get far enough underneath the built-in abstractions, and users always want 100% of what they want" - but it's generally applicable
SO YOU'RE GOING TO DIE: The Comic for Dealing with Death
Why are you even asking? jQuery has such little overhead that if you want to be "adept" at it for maintenance or basic tasks, all you need to do is use it a few times.
This isn't some complicated language and you're not going to be building anything incredibly involved with it (you should use JS for that stuff, anyways). Hell, it's not even a language in it's own right. You're only going to be using so much of it anyways. See if there are any free interactive tutorials to help you take the training wheels off and then just use it. Become familiar with it and learn how to navigate the documentation. Done.
It is only breakage prone if you are bad and use $. Just save yourself a shitload of headaches and type jQuery() instead of $(). Then later when you feel even more hipster you can start duct taping more random.js junk to your project and none of your jQuery code will [most likely] not conflict with them. I won't even touch Javascript without jQuery. It's nice being able to do things like [for].each() with no effort like languages should have natively.
I actually did. Maybe we have a different sense of humour.