Is there anything that jQuery does that JavaScript can't do?

Question

Is there anything that jQuery does that JavaScript can’t do?

Answer

No, JavaScript can do everything that jQuery can do. jQuery is written in JavaScript allowing jQuery to have only the behavior that JavaScript supports, if JavaScript can’t do something, neither can jQuery. That said, jQuery can make JavaScript faster to write and easier to read.

For a simple example, let’s compare selecting all elements that have a class="my-class" attribute:
In JavaScript:

const myClassElements = document.getElementsByClassName('my-class');

vs
jQuery:

const $myClassElements = $('.my-class');
6 Likes

I am wondering tho.

Since Jquery is made from Javascript i expect Jquery to be slower when executing complex code/calculations because i imagine code running on code.

Is this true ?

to truly understand jquery, we need to go back in time.

When jquery was released, writing cross browser code was a disaster. Jquery solved this. Jquery also made the code a lot simpler then vanilla JS code.

However, there was still one major problem: DOM manipulation is expensive/heavy. Browsers where never designed for what they are today. (lots of DOM manipulation)

to overcome the dom manipulation problem, we now have libraries/frameworks like reactJS and vueJS. So jquery is losing ground there. If a web application needs heavy DOM manipulation, developers will choice vueJS/reactJS or something else.

jquery is also losing ground when it comes to AJAX, tools like fetch, axios and websocket are now preferred.

sure, if you just need simple DOM manipulation, jquery can be okay. Jquery is still easier and faster to develop in then vanilla JS.

the history of web development, browsers and there language(s) is an interesting one.

12 Likes

Is it a good decision to learn and use JQuery in 2019?

Languages/libraries/frameworks are just a tool to get the job done, learn whatever you need for a project

Jquery can still be useful for simple DOM manipulation, so yea, you can still consider learning it.

3 Likes

nobody can write it better!