A simple analogy: You could just use a pre-made wheel or you could make your own (“don’t reinvent the wheel” is a common thing you’ll hear in the dev communities).
This has some good high level info. https://symfony.com/why-use-a-framework
In short, they save you time by solving common problems with generic functions you can write in a much shorter time frame than using the vanilla. That goes for any language. What they do depends on the framework.
e.g. from the site I linked ^
As an example, a framework will keep the developer from having to spend 2 or 3 days creating an authentication form (which is not a specific task). The time that is saved can be dedicated to more specific components as well as to the corresponding unit tests; giving you solid, sustainable and high quality code.
Again the summary from that link ^
A framework is not an absolute necessity, but nonetheless it is very useful.
A framework is a pledge of quality, upgradability and maintainability of applications at lower cost.
Applications developed using a framework are interoperable with market standards.
What you get depends on the framework. There’s some overlap and pros and cons to each. It’s best to read up on them to see if they fit your needs.
In short, they are there to meet the demands of today’s web app. They don’t add anything to your plain JS; knowing vanila JS is pre-requisite for learning them. Once you are working with one of them, you are working with their way of doing things.
It is hard to appreciate why they exist without hitting the bottleneck of traditional web apps. I’m not not in this group, but I just like their way of thinking.
Job market alone is a pretty good reason to learn them, although it depends on where you live.
As to why they exist… As far as I remember, at some point
- mobile devices were becoming a dominant way of accessing web.
- mobile devices got faster, but they still had significant network latency.
- web applications wanted to do more complex things by demands of users.
So, the need for single page application that handles many things without requesting another page refresh kind of got important for complex web apps. However, DOM was slow; so, putting more client code became less performant. Also, many people disliked how things were done in JQuery because it was working with physical DOM, it was difficult to write reusable components, and it typically resulted less maintainable code in large code base with many programmers working on it. So, frameworks that avoid these things were written.
I don’t know much about React but this is the most happening product by facebook. JS frameworks are made in JS to help developers do complex tasks quickly.
Imagine you are an accountant.
When accounting started out, all you had was a ledger and a pencil. Then they invented calculators and adding machines. Then spread sheets and custom software. Yes, you can still do accounting with a calculator. But for large-scale accounts that’s going to get unmanageable and increase the chances for mistakes.
Frameworks help you manage large projects and reuse components and code. It makes it faster, easier, and less prone to mistakes. Sure, many small sites don’t need this, but you’ll eventually reach a point where you do.
The way I see it, frameworks add standardization, organization, and answers to commonly confronted developer problems.
Standardization and Organization
- Helps when you’re working on a team, or when you need help doing XYZ and want to go searching on the internet for help doing XYZ. You and all the other devs online will be speaking the same vocabulary. Think about it this way: If everyone had their own SUPER-SPECIAL-UNIQUE-“My ways is the best!” way of organizing their code, (aka the web in the 90s), it makes looking through other people’s code and helping them much harder. Even if you think it’s currently very organized, your future self who comes back probably will have to figure out what you were even doing from the ground up again.
Answers to commonly confronted dev problems.
- Don’t reinvent the wheel if you don’t have to.
You don’t need to learn a framework at all. If you can get it done in vanilla JS, more power to you. But as your project gets larger, older, or adds more people to it, chances are the benefits of incorporating a framework (such as one of the two above I just listed), will become more and more apparent.