kabir kPro Student 18,036 Points
Also, under what circumstances should one use one over the other?
Erik KriegTreehouse Moderator 42,776 Points
Hi Kabir! Here is a quick comparison:
The downside of vanilla JS is that it is easier to make mistakes or miss something, is less beginner friendly (than jQuery), and can require you to develop more code to accomplish goals the would take much less time with jQuery.
The primary benefit of jQuery is the reduced development time it offers web devs and its easy to use API and numerous plugins. Also, when you use jQuery you are still writing some vanilla JS, so it is not truly one or the other.
The downside is that by adding it to your project you might bloat the resources you need to load, call unnecessarily verbose methods, and avoid learning how the language actually works.
How to choose
jQuery is a fine choice in the following situations:
- For small projects where perfomance is not a big issue
- Simple projects with a tight deadline
- Large projects that use an MVC library or framework that has jQuery as a dependency
Now, times you might not need jQuery include:
- Acquiring an intermediate - advanced understanding of JS
- Working on complex web applications
- Building you own library or framework
- Server side applications with Node.js
Here is some more on the topic.