Difference between a Framework and a Library : Javascript point of view

While attending interviews for programming jobs,one of the most common question you would face is to explain the difference between a libarary and a framework.Here in this article we look at the difference between a library and a framework from a Javascript point of view.


Libraries provide methods/functions/modules  that can be useful while building your application.While using a library the control is with your code and you call the functions the libraries provide from within  your code.These functions are reusable and can be used at different parts of building your application.There are many Javascript libraries like JQuery,JqueryUI,moment.js etc.These libraries provides functions that serves different purposes.


So we can generally describe the working of a library as

  • We call the library functions from from our code
  • Flow Control is with our code               

For example when using JQuery library, we include the library in our code and call the library functions from within our code in the following way


A framework provides structure,resources for building your application.While using a framework you call your logic from within the framework .The control is with the framework code , your code is called when  logic is needed and the control is inverted back to the framework .This is called inversion of control / Hollywood principle(“Don’t call us, we’ll call you).


So we can generally describe working with a framework as

  • We call to our code  from framework
  • Flow Control is with the framework.When needed our logic is applied and control goes back to the framework.

There are many JavaScript libraries available like AnguarJS , Vue.js.

We look at the working of a framework taking AngularJS as an example. While building an AngularJS application,the framework gives the routing methods for our application.When it has to render a view it calls  for our bit of code.

Remember,the  framework may or may not use multiple libraries depending upon your choice of framework.Most framework makes use of many libraries.



framewor and library


No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *