Table of contents
No headings in the article.
In web development, we frequently hear the terms library and framework. “What is the actual difference between framework and libraries?” is a question that has often crossed our mind prior to project setup when selecting frontend libraries and frameworks.
Both frameworks and libraries are the collection of reusable code written by someone else that shares the goals of decreasing workloads and increasing efficiency through standardized patterns.
But, the key difference that sets it apart lies in its flow of control.
In frontend libraries, the parent code uses the functions offered by libraries whereas, in frontend framework, the framework itself calls the code and uses it in the specific way as required.
Let’s gain a clear snapshot of the framework and libraries before moving on to the differences.
What are Frontend Libraries?
Frontend Library is a collection of pre-written code, predefined methods, classes and objects that developers can use to add specific functionality to their websites/web applications.
Some of the Popular Frontend Libraries are:
What are Frontend Frameworks?
Frontend framework is a pre-made library, compilers and API that is intended to be used as a base in the development of particular website/ web applications.
It is essentially used as a foundation so that developers don’t have to start from scratch when writing the code.
Some of the Popular Frontend Frameworks are:
Relating Framework and Library to real world examples
Imagine we’re building a house, the blueprint (Frontend Framework) gives the builder the basic structures and guidelines for what the house should look like. In a similar manner, the frontend framework gives developers a set of tools and components to build websites or web applications.
In the process of building, just like the builder purchases the pre-made doors and windows (Frontend Library) to add it to the house, in a similar way, developers use frontend libraries to add functionality to their build websites or web applications. For instance, if the website requires an image slider, we directly import the library containing the image slider’s pre-written code. As a result, writing the code for the image slider requires less additional work and time from the developer.
Summarizing
Putting simply, the “Inversion of Control” (IoC) describes the difference between a library and a framework. By using a library, we control the flow of the program. The library can be invoked whenever and wherever we like. In contrast, when we use a framework, the flow is controlled by the framework. Although the framework tells us where to place our code, it will still call our code when necessary.