Official technical definitions
Before we can define jQuery as either a library or a framework, we need to know the exact technical definitions of both.
Techopedia defines software library as follows:
A software library is a suite of data and programming code that is used to develop software programs and applications. It is designed to assist both the programmer and the programming language compiler in building and executing software.
This is not dissimilar from the definition provided by Encyclopedia.com:
A collection of programs and packages that are made available for common use within some environment; individual items need not be related. A typical library might contain compilers, utility programs, packages for mathematical operations, etc. Usually it is only necessary to reference the library program to cause it to be automatically incorporated in a user's program.
Based on the above, a software library is something that you, as a programmer, would call into your code. It's main purpose would be to assist you by providing a useful set of functionalities, so you would not have to write those from the scratch.
When it comes to the definition of a software framework, Techopedia has the following definition:
A software framework is a concrete or conceptual platform where common code with generic functionality can be selectively specialized or overridden by developers or users. Frameworks take the form of libraries, where a well-defined application program interface (API) is reusable anywhere within the software under development.
Based on this definition, one can be forgiven to think that framework is nothing more than a restrictive variety of a library. However, the same page on Techopedia then provides a more detailed definition, which consists of the following:
Certain features make a framework different from other library forms, including the following: Default Behavior: Before customization, a framework behaves in a manner specific to the userâ€™s action. Inversion of Control: Unlike other libraries, the global flow of control within a framework is employed by the framework rather than the caller. Extensibility:A user can extend the framework by selectively replacing default code with user code. Non-modifiable Framework Code: A user can extend the framework but not modify the code. The purpose of software framework is to simplify the development environment, allowing developers to dedicate their efforts to the project requirements, rather than dealing with the frameworkâ€™s mundane, repetitive functions and libraries. For example, rather than creating a VoIP application from scratch, a developer using a prepared framework can concentrate on adding user-friendly buttons and menus, or integrating VoIP with other functions.
Therefore, although it is not wrong to say that a framework can be defined as a library or a collection of libraries that demand a specific style of programming, it is much more then that. It is a foundation on top of which the rest of the code is build. So, while the standard libraries are called into the code to provide assistance, framework is something that is put into place before the code is even written.
How these definitions apply to jQuery
jQuery certainly meets the definition of a library. It is a collection of functionality that developers can add into their code. Its main purpose is to provide the ability to call repeatable complex logic by entering just few lines of code. However, some argue that jQuery meets the definition of a framework as well. Therefore, let's take each point that defines a framework one by one and see how jQuery fits within it.
What exactly is default behaviour of a framework? A book titled"Formal Description Techniques and Protocol Specification, Testing and Verification" defines it as follows:
The default behaviour of the framework is to call virtual procedures or call-back procedures. The user of the framework redefines these procedures to what is special for the application.
Inversion of Control
Inversion of control occurs when, instead of getting your code to call an external object, the external object calls your code. In order to do this, the imported framework needs to be able to read your code.
jQuery is capable of calling your code. You pass your own anonymous functions into jQuery functions as arguments and from within these functions (which get executed inside jQuery) your named functions can be called.
It is difficult to argue that jQuery is not extendable. There are countless of other libraries and frameworks that depend on standard jQuery and extend its functionality. jQuery UI, for example, extends its functionality to make user interface more pretty and responsive. So does Bootstrap.
jQuery was designed to enable easy development of extensible plugins. This page shows an example of how to make one.
Non-modifiable Framework Code
JS frameworks are officially classed as frameworks because, by mutual consent, web developers decided to relax the definition of "non-modifiable framework code", based on the fact that the frameworks are merely intended not to be modified. So, although there is nothing that physically stops you from modifying the code, doing so would violate best practices of web development.
The most important thing is that it is not important
Whether you refer to jQuery as a library or a framework, it doesn't affect your programming abilities in any way. In my career as a web developer, I have seen many good developers who refer to jQuery as a framework and equally as many bad developers who refer to it as a library.
There are people who will tell you that you are likely to be kicked out of a hiring process if you will get the definition of jQuery wrong, but this is not the case. Any good software team will care much more about your ability to use jQuery than what you chose to call it. This is why, during a job interview, you are much more likely to encounter practical coding tests rather than a general knowledge quiz.
There are, of course, places where you can fail a job interview if your definition of jQuery doesn't match the interviewer's definition. These typically fall under two categories: over-zealous seniour developers or non-technical hiring manager who don't have a clue what the answer is, as long as it is the answer that is written on their sheet. Usually, places where you would encounter either of these are the places you would need to avoid. Excessively militant seniour developers would make your life hell by starting an argument over any little terminology mistake. Imagine working with Sheldon Cooper from Big Bang Theory! The companies who place non-technical recruiting managers to conduct technical job interviews are usually places where non-technical managers make highly-technical decisions and make them badly. Therefore, if you have been turned down a job for getting the definition of jQuery wrong, don't worry. Quite likely, the company did you a massive favour by not hiring you.
Written by Fiodar Sazanavets
Posted on 30 Nov 2016