DEV Community

Cover image for Vanilla JS or Framework?
Ajibola jr. MSc, Cybersecurity
Ajibola jr. MSc, Cybersecurity

Posted on • Edited on

Vanilla JS or Framework?

This question keeps popping up in the mind of almost every front-end or full-stack developer, especially the newbies. They will be like, 'Which one should I go for?' Vanilla JS or framework? Vanilla JS is when you write pure JavaScript, for example:
const trigger = document.querySelector('.element');
trigger.addEventListener('click', (e)=>{
/* some code here */
}
The thing is, using a framework might not be the best option for a beginner. If you are just starting out, starting from vanilla JS will be a great one for you because when you jump straight to a framework, there are some things working in there you won't have the idea of how they work or the logic behind them, plus you're going to find it difficult to tie your head around it. Now let's highlight the advantage and disadvantage of using both.

  1. Vanilla js (advantage) js
  • The beauty of knowing vanilla JS is that you can learn any web framework, e.g., React, Angular, Vue, Backbone and so on.
  • Using vanilla JS for your app will put your mind at rest because your app won't depend on crazy quick-changing JS ecosystems.
  • Vanilla js (disadvantage)
  • The only disadvantage we have with vanilla JS is the limited time; we have to start writing our code from scratch. Imagine before you start writing const div = document.getElementById('element'); and so on, just to achieve a click event; it is somehow terrible and time-consuming.

js-cofee

  1. Framework (advantage)
  2. The pretty big advantage of choosing a framework is that there is ease of time in doing a lot of things.
  3. It has a lot of pretty predefined functions you can use without you having to write 50 lines of JS. react

angular

vue

  1. Framework (disadvantage)
  2. Some frameworks are very bulky when it comes to functions with large set of powerful features and a codebase, e.g., Angular.
  3. Using a framework without having the in-depth knowledge of vanilla JS might not be a good one for you because some things will look like magic to you.

So if you are just starting as a developer, i will advice you start from vanilla js then once you're very comfortable with vanillaJs, pick up any framework of your choice and learn it with ease.

Please, do not hesitate to share your opinion in the comment box below...
Thanks for reading...

Top comments (0)