VehiclesFashionRecipesBlogsHuntTravelsSportFunHandmadeITEducation
Mini-Games
x

x
zakruti.com » IT - Software » freeCodeCamp.org
jQuery vs vanilla JavaScript - Beau teaches JavaScript

jQuery vs vanilla JavaScript - Beau teaches JavaScript

FBTwitterReddit

video description

Rating: 4.0; Vote: 1
When should you use jQuery instead of vanilla JavaScript? Is jQuery still relevant? What is jQuery good for? Find out in this video! - Video based on this article by Ollie Williams: https://css-tricks.com/now-ever-might-not-need-jquery/ The only polyfill you'll ever need: https://polyfill.io - Beau Carnes on
Date: 2022-03-14

Comments and reviews: 7


I wrote a hundred lines of jQuery yesterday (including comments), then decided to use vanilla js instead. It took me 170 lines to write the same functionality. (NB: My vanilla js was slightly more efficient code because it was the second time I wrote the same app, so I had refactored some stuff). So I'd estimate the jQuery probably had about half the lines of code overall. The main reason why the jQuery was slightly leaner (in terms of lines of code) was because of the ability to chain statements together, rather than reselecting elements.
I think jQuery has a slight advantage in terms of readability... but it's not a big deal.
In my case, jQuery is probably still the best option, because I'm likely going to want to use jQuery UI as the app develops. Otherwise I'd have to rewrite some of the same functionality jQuery UI provides.
As with everything, I guess it all depends on what you need to do. If all you are doing is basic web enhancement stuff, vanilla js is perfectly fine. But the more you go beyond that, the more you appreciate out of the box solutions...
I think it's great though that js is evolving into a leaner and more powerful scripting language. And when you combine it with CSS3, you've really got a lot more power and flexibility than we had previously.

reply

i am doing this usually
function $(selector) -
let elems = document.querySelectorAll(selector);
return elems.length > 1 ? Array.from(elems) : elems[0];
-
let elem = $('.someClass');

reply

When you say to place that polyfill script tag at the top of your website, where exactly do you mean? In the head of the document? Does it matter what comes before or after it?
reply

Wish the dude would stop saying they're exactly the same at the beginning. They are not. Very very similar? Yes. Exactly identical? No. Beginners need precision to learn.
reply

I personally don't find much of an advantage with Jquery, apart from a bit of advanced animation.
I find the javascript syntax very clear and easy to understand now,

reply

so finally what's bad about using JQuery? it's clear that JS is almost as good as JQuery, but what are the exact reason why should i use the less convenient way?
reply

There are a lot of other jquery methods you didn't mention which is much harder to implement in plan js. For example, find and close, do they exist in plain js?
reply
Add a review, comment






Other channel videos