This website uses cookies on its adverts and sponsored links. By clicking the "Accept" button you are consenting to their use.

Read more

Accept


MobileTechTracker
≡ sections
Home

Apps

TrackerBlog

GeekHub

Tech News

About

Welcome to Mobile Tech Tracker. Our mission is to help technically-minded people to become better versions of themselves and to help ordinary people to use modern smart technologies to their own advantage.


Is jQuery a library or a framework? The answer may surprise you.

What is jQuery exactly? Is it a library or a framework? This question occasionally pops up on various web development forums, asked by both novices and experts. As jQuery is one of the most heavily used JavaScript-based tool in the world of web development, it is not surprising that many people feel that it is important to learn what it is classed as. Also, surprisingly, this specific subject is something that many web developers feel militant about. I have seen people being viciously insulted on web forums for getting the definition wrong.

The most common answer to this question is that jQuery is a library. And indeed, this answer is correct. After all, the official jQuery documentation defines the tool as "a fast, small, and feature-rich JavaScript library". But is the answer as simple as that? Are those who refer to jQuery as a framework really mistaken? In this article, I will argue that the answers to both of these questions are no.


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.

Software library

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.


Software framework

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.

Default behaviour

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.

Arguably, this is EXACTLY what jQuery is all about. It consists of a collection of procedures and call-back procedures that can be called without any specific parameters, but they only become useful when document-specific selectors are applied to them. Some will argue that what I described as default behaviour in jQuery really isn't something what would be classed as default behaviour in a framework. Proponents of this arguments will say that all functional components of jQuery are nothing more than a standard library functions and no default behaviour will be observed until you will actually start adding jQuery statements into your code. But in the context of JavaScript, this really isn't the best argument. Although some JS frameworks, such as Bootstrap really changes the default behaviour of your HTML and CSS, other frameworks, for example AngularJS (which nobody refers to as a library), will do absolutely nothing until some code or markup specific to the framework is placed on the page. Therefore the presence of framework-like default behaviour of jQuery is up for debate.

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.

Many will argue that this behaviour has nothing to do with inversion of control. There is nothing special about passing anonymous function as parameters in JavaScript, just like it can be done with any variables. So you still are just calling library functions with your own custom parameters, just like any library would allow you to do. However, there is another aspect of jQuery behaviour which almost certainly can be classed as inversion of control.

Some of the most powerful features of jQuery are DOM manipulation and event handling. Both rely on jQuery having full access to the markup on your page that it can manipulate and JavaScript code that it can execute. Although people do interpret inversion of control differently and some will argue that this behaviour of jQuery does not fall under its definition, many will say that this behaviour is not much different from what is classed as inversion of control in other types of applications.

Extensibility

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

This point is an interesting one. Although jQuery is intended to be used without modification to its own source code, there is absolutely nothing that stops you from modifying it. So, this proves that jQuery is not a framework, right? Wrong! As every JavaScript framework is nothing more than imported interpreted code from files that you have a full control over, absolutely any of them can be modified. This brings us to an interesting point of discussion.


Is there even such thing as a JavaScript framework?

Although we have shown that, depending on interpretation, jQuery has all the properties that define any other JavaScript framework, many will argue that jQuery doesn't meet these definitions strictly enough. However, if we are to be absolutely strict, then there isn't a single JavaScript framework out there that fully meets the definition of a framework.

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.

If the definition of non-modifiable code has been relaxed in the domain of JavaScript, then there is no reason why anybody should be militant towards those who call jQuery a framework based on non-strict interpretation of framework definition.


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

Posted on 30 Nov 2016

Comments (0)

Author's Name *

Email *

8 + 4 *

Comment

*


More from GeekHub


How big data web applications are built

How big data web applications are built


Where to start if you want to become a hacker

Where to start if you want to become a hacker


What to study to become a mobile app developer

What to study to become a mobile app developer


6 creative ways for a software developer to earn money on the side

6 creative ways for a software developer to earn money on the side


Software design patterns explained

Software design patterns explained


What to study to become a web developer

What to study to become a web developer


Why is there a limit on SD card capacity on mobile devices

Why is there a limit on SD card capacity on mobile devices


How traffic predictions and live traffic work

How traffic predictions and live traffic work


What is PAC and how mobile numbers are ported

What is PAC and how mobile numbers are ported


3 reasons to use strings.xml in Android application

3 reasons to use strings.xml in Android application


Share this:

Facebook Google LinkedIn Twitter

Mobile Tech Tracker - Blog Directory OnToplist.com

Software
Blogtoplist

Top Blogs

BlogrollCenter.Com

Blog Directory



More from GeekHub











Privacy Policy

© MobileTechTracker. All rights reserved. Unauthorised copying of any of this website's content is prohibited under international law.

For any queries, comments or suggestions, please write to info@mobiletechtracker.co.uk.