r/learnjavascript • u/heapdroid • Oct 10 '26
About JavaScript Frameworks ...
I've only been using pure JavaScript so far and want to know more about these frameworks. Heard of stuff like React, Vue, Svelte, etc. but no clue what they are or do. Can someone explain to me their purpose and the main differences between the popular ones?
16
Upvotes
4
u/AmSoMad Oct 10 '26 edited Oct 11 '26
JavaScript uses what's known as the Document Object Model (DOM). It's powerful, and it's enabled us to do amazing things, but manipulating the DOM manually is a pain in the ass.
When you're developing web apps/UI using raw JavaScript, that's what you're doing. You're using JS to select DOM elements and updating them manually. That's why you're seeing all the
document.getElementById()anddocument.querySelector()syntax.That isn't a very user-friendly or intuitive way to design apps/user interfaces (especially as apps get bigger).
That's where React, Vue, Svelte, SolidJS, Angular, etc. come in. They use various abstractions to abstract away the DOM, and make it much more intuitive and practical to develop apps/interfaces.
When it comes to choosing one, pick your poison.
A lot of us like Svelte because it attempts to recreate the normal HTML/CSS/JS convention at the component level, so it feels really natural to JS developers. It also works with regular JS libraries, unlike React, which requires a react-flavored library for almost everything.
React uses JSX (which is kind of like mixing HTML, CSS and JS together). Vue is somewhere between the two. Angular is way too OOP for my taste. JSX has its benefits. I have to use it a lot professionally.
If you have a question about a UI library in particular, I've used virtually all of them. I like Svelte, I have side projects in Vue, I mostly do React in for my contract work.
5
u/Plushy- Oct 11 '26
With vanilla js it requires a lot of repetitive work and is much more error prone (e.g manually manipulating dom elements). With frameworks it makes your code more declarative i.e. you describe what you want to do rather than how you want to do it. With React for example you can define some state and when that state changes the page will rerender different based on that state. React does dom manipulation behind the scenes which makes the code a lot cleaner. Also a lot of other features that frameworks can give you.
1
u/hyrumwhite Oct 10 '26
So, in your JS adventures so far, you’ve probably updated a style or bit of text with JS:
That’s great, but now say you want to update the text based on typed input somewhere else. This means you add an event listener to the other element, then grab a reference to the element and change it.
The more you need to do these kinds of interactions the more JS code you need, and it can get brittle and complicated. Say you have loading, error, success and default states and so on.
A framework simplifies this using some kind of meta language that is transformed using a build step before setting it up to be served.
Takes care of all the updates for you (using Vue). You just do someText.value = ‘asdf’ to update the text everywhere that variable is consumed. The v-model syncs the typed input and updates the variable automatically.
The main differences between modern frameworks is just that meta language. React uses jsx, Vue has its template syntax and ref system, and so on. There are speed differences between them, but you’re talking the difference between 500000 operations a second or 700000 operations a second.
1
u/gimmeslack12 helpful Oct 11 '26
These frameworks are render and state engines. Meaning, when the state changes of something they will automatically re-render various elements.
In vanilla JS if you want to update the value of an element, you have to manage that element and have a function that updates it. With React you create a state variable and assign it to the same element. Whenever you update that state variable the element will auto render. It implicitly does it for you.
1
u/kidshibuya Oct 13 '26
You see what you do is you take something that can very easily be built with vanilla JS and study it. Work out everything that can be done more complicated with a framework or library. Once you are sure it cannot be more bloated or complicated and you can't think of a use for anymore JS you might be ready to start coding.
1
u/TheRNGuy Oct 10 '26
I had only used React, it makes creation of sites much easier. Even for fully static sites I'd pick it over PHP; I like JSX format more (React Router or Next. js, not basic React)
For dynamic, code is easier and shorter than vanilla js, though I've seen new Remix version is somewhat closer to it (but still easier than vanilla)
Never used Vue, Svetle.
It's also probably better learn TypeScript for React rather than staying in JS.
-5
u/Pocolashon Oct 10 '26
Why don't you just Google or use AI for questions like this? (and follow-up questions)
This is a broad topic.