128

Here, jquery is mentioned under framework category: http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks

Is jquery a javascript library or framework?

Eric Leschinski
  • 123,728
  • 82
  • 382
  • 321
rahul dagli
  • 1,598
  • 5
  • 14
  • 16

7 Answers7

174

A library. According to the homepage, and which I agree with.

A framework is something that usually forces a certain way of implementing a solution, whereas jQuery is just a tool to make implementing what you want to do easier.

GregL
  • 32,302
  • 7
  • 58
  • 64
  • 59
    +1. A library is something you call from your program. A framework is something that calls into your program. – Thilo Aug 15 '11 at 08:10
  • 2
    For library vs framework comparison, see "Inversion of Control" http://stackoverflow.com/a/3057818/2144912 – cheshireoctopus Jun 30 '16 at 03:23
30

jQuery: The Write Less, Do More, JavaScript Library.

Dunhamzzz
  • 14,036
  • 3
  • 47
  • 73
  • 14
    While I agree, a self-given name/slogan proofs nothing. There are thousands of so called "frameworks" out there are actually libraries. – kapex Nov 07 '13 at 17:44
  • @Kapep but the reversed case is less common: not many frameworks call themselves "libraries". I guess the term "framework" sounds sexier to some… – Franklin Yu Nov 20 '17 at 02:52
19

For sure, it's a javascript library. But about being a framework or not,I just think it's not a framework. Have a look on wikipedia definition of software-framework:

It is a collection of software libraries providing a defined application programming interface.

And jQuery is just a single library. After that it says:

Frameworks contain key distinguishing features that separate them from normal libraries:

  1. inversion of control - In a framework, unlike in libraries or normal user applications, the overall program's flow of control is not dictated by the caller, but by the framework.

So, I think it's not a framework.

Community
  • 1
  • 1
Saeed
  • 6,520
  • 12
  • 37
  • 61
9

According to the angularjs web site

  • a library - a collection of functions which are useful when writing web apps. Your code is in charge and it calls into the library when
    it sees fit. E.g., jQuery.
  • frameworks - a particular implementation of a web application, where your code fills in the details. The framework is in charge and it calls into your code when it needs something app specific. E.g., durandal, ember, etc.
Harke
  • 1,209
  • 4
  • 23
  • 29
7

Framework and libarry are not necessarily mutually exclusive terms. Framework is typically a libarry or a collection of libraries.

Strictly speaking, jQuery is a library, but, to an extent, it does meet the definition of a software framework. Although many would argue that jQuery doesn't meet the definition of a software framework strictly enough, the fact is that no other JavaScript framework fully meets the definition of a framework either.

One of the defining characteristics of a software framework is that its code is protected from modifications. In JavaScript, this clearly isn't the case. Any libraries or frameworks that can be called into your client-side code are modifiable, although it would be against best practices to alter them. Therefore, if it is permissible to call Bootstrap or AngularJS a framework, there is no reason why jQuery cannot be called a framework either. This link contains a more detailed explanation of how jQuery meets the criteria to be called a framework.

Perhaps the best explanation of why jQuery is more of a framework than a library is the fact that as a developer, you can chose not to use any of its framework-like functionalities. You can, for example, mix a simple jQuery statement with a standard JavaScript statement on the same line. AngularJS and Bootstrap typically don't allow you to do this. Therefore, the accurate answer whether jQuery is a framework or not is "it depends whether you chose to use it as a framework or not".

2

I agree with all the answers here that jQuery itself is indeed a library, not a framework. As specified by Saeed's answer, one of the key distinguishing features is inversion of control. You could however use jQuery's functionality to create a framework of your own.

Examples: there are projects built on top of jQuery that are defined as frameworks: jQuery Mobile: A Touch-Optimized Web Framework, JavaScriptMVC and sammy.js to name a few.

There are also other libraries built on top of jQuery, like jQuery UI

Some of it seems like semantics when defining what a library is vs a framework, but those examples help draw the line for me.

Durandal
  • 5,048
  • 4
  • 31
  • 45
1

If we talk about Inversion of control, which almost everyone in the above thread talks about then jQuery is a FRAMEWORK.

It has got IOC e.g when we write the function $(document).ready{}...it is the container which calls this method and we simply put our code inside the braces. We are not the Caller of this method and hence "Inversion of Control"

This way jQuery is a FRAMEWORK.

pinkman
  • 134
  • 1
  • 5
  • 1
    Meh, most sizeable libraries provide at least some sort of vaguely callback-ish method for some purpose. You can write a lot of jQuery code without ever relying on `ready()`. – Nathan Tuggy May 14 '17 at 06:01
  • @NathanTuggy So why even the detailed discussion about Framework vs Lib talks about IOC. If it is there, it is there. Why talk about "relying" or "not relying". – pinkman May 14 '17 at 11:58
  • Because framework-style IoC is characterized by the *necessity* of using it. Not the possibility of using it, as desired, in specific ways, a la carte. In a framework, you don't have a choice: control *is* inverted. – Nathan Tuggy May 14 '17 at 13:28