dots Created with Sketch.
Yogesh Chauhan's Blog

What’s the difference between a Framework and a Library?

in Miscellaneous on June 25, 2021

We use these terms almost everyday as developers. These are my notes regarding both with examples and differences.

A framework and a library both contain reusable functions.

You can write a library with reusable functions too that can be used by other developers. There are tons of custom CSS, JavaScript and other libraries available on GitHub. Most of them are shared by other developers as an open source project and anyone can contribute in it, others are private and can be purchased.

Library

A library is basically a set of functions that adds more functionality to your project.

When you need to perform some task, you can call one of those functions. In many cases, the functions are made for an instance of a particular class so you need to create the instance first and then call the function.

Your project is ready but you can add or remove libraries based on your need. It’s like your house or car. It’s already built but if you want to make it look nicer or add some additional “features”, you can go to some stores and get stuff to add. You don’t need to create a new car just to decorate it!

Examples: React, jQuery, Three.js, Lodash

Framework

A framework is different in that sense. It’s like a skeleton.

It’s like you have a set of features or functionalities in your mind and you need to decide from the beginning which “tool” aka framework to use to accomplish that.

Kinda like making a car or house from scratch! Yes, like making Ferrari or similar cars from scratch. Once you go with a Ferrari, you can not have some features from Tesla. For that, you need to swap the Ferrari for Tesla.

A framework has more functionalities built in. Some of those functionalities / features / functions gets fired on a specific behaviour of users or the app, other times, you need to add some kind of specific behaviour in order to fire those functions.

Examples: Angular, Vue, Django, Express

You might have got the idea regarding the technical difference. It’s about the control.

When you use a library, you have much more control over it but when you use a framework, you lose most of that control.

It’s all about what level of freedom you want as a developer.

amazon

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jul 22 Is there a CSS parent selector? #Jul 22 Difference between :where and :is in CSS #Jul 22 Does :is() pseudo selector hint at CSS preprocessing in the future? #Jul 22 Control Scrolling with CSS Scroll Snap #Jul 21 Control rendering using CSS content-visibility property #Jul 21 How to use @supports rule in CSS?
You might also like these
How to add AppRoutingModule in Angular application using command line?AngularThe Difference Between Arrays and Objects in JavaScriptJavaScriptUseful (and probably ignored) HTML tags: Part 2HTMLHow to overwrite file contents with new content in PHP?PHPHow to Access a Global Variable From Inside a Function in PHP?PHPList of WordPress directories functionsWordPress