What is the difference between a framework and a library in JavaScript? Why is this confusing?
It's sometimes hard to get a straight answer, but if we focus simply on the architectural design details the difference becomes quite clear.

Search for a command to run...
It's sometimes hard to get a straight answer, but if we focus simply on the architectural design details the difference becomes quite clear.

No comments yet. Be the first to comment.
Are you listing your apartment for sale? Great! A shiny new listing online, beautiful photos, a detailed description... But you know what? For a buyer, it's just information. For a thief, it's a ready-made plan of attack. It may sound like a scene fr...
How can you satisfy your curiosity in your free time? How can you combine your free time with learning and deepening your technical knowledge? How do you feed that curiosity that keeps growing as you dive deeper into the unknown? There are certainly ...

In the era of the Internet, especially today, when even companies specializing in cybersecurity fall victim to hacker attacks, the question arises: is it possible to win a fight that seems lost from the start? If companies that have been developing s...

In today's world, cyber-attacks are becoming increasingly sophisticated, posing significant challenges in combating cybercriminals. Virtually every imaginable device is interconnected via the Internet, enveloping us in the cyber realm. Cybercriminals...

A fiber optic cable LC type is visible above.

On this page
Let's take a few minutes to answer this question. The topic is difficult to cover due to inconsistencies. Additionally, programmers use the two words "library" and "framework" interchangeably. This is where the misunderstanding is born. If we begin to delve into this topic, we may be more confused than before. People who yesterday used the term "library" for "framework" are using different terms today. There are many uncertainties here. I understand one difference.
First of all, "libraries" and "frameworks" were created to solve common and recurring problems. They were written by developers to make it easier for everyone and the whole host of programmers to write.
All in all, there is nothing extraordinary and magical about both. Both the library and framework were written for multiple uses by someone else. Purpose - To facilitate the resolution of common problems.
If one person had defined these two terms, there would not be so many discussions, misunderstandings and inconsistencies. Unfortunately, this is not the case. Both terms are and have been defined by the developer community. This makes the use of these words interchangeable and the treatment of them looser.
For example, very often in JavaScript, we create AJAX queries, manipulate the DOM. We don't want to write the same code now and then, do we? Same, identical code in 5 different projects? Why not create reusable code that will speed up your work at the same time?
In the library, just like in life. You enter the library, you are looking for the book you want to read. The library allows you to choose the book YOU WANT. You are in control. Same in JS. Suppose you often need simple math functions.
function addTwo (a, b) {
return a + b;
}
function multiplyTwo (a, b) {
return a * b;
}
function substractTwo (a, b) {
return a - b;
}
Well done, you wrote a simple but your library!
Pros of the library
In the framework, just like at work. You go to her, you have specific tasks, you do not have full control. The framework is like building a house. You have a specific plan, budget, limited choices. You're sticking to the frame. The contractor is in control here. You can bring something when needed.
Pros of the framework
I think you can already see the difference between the library and the framework. It's about control. The technical difference is in the concept called inversion of control.
If you use the library, you choose when and where to use it. You are responsible for the flow of the application.
If you use a framework, the framework is responsible for the flow. It gives you several places and options where you can enter your code. It gives you a framework within which you can move around. If you fill in the blanks, the framework will call and execute your code as needed.
Conclusion
Of course, libraries and frameworks also have their drawbacks. The framework is used to create and deploy applications faster. We must always be up to date with new versions and news. When choosing a framework, you need to delve into its ecosystem and understand it. The library extends and increases the functionality of the application. When creating your own library, you can use it many times.
Framework reverses control of the application. He tells the programmer what he needs.
You are in control of the library. You call it when, where and how many times you want.
Working with the library you have full freedom, and with the framework - you stick to the framework defined by it.