Is jquery a **normal** library to javascript the same way Math is a library to c++, python or even js?

197 views Asked by At

I'm new to web development, I'm discovering javascript and all its capabilities. I'm currently learning jQuery and it made me wonder: "what really is a library ?".

From some so/internet search I understand that jQuery is a library, although some people also consider it a framework as it help/force you to change the way you code js.

For me, a library is a set of functions and classes to help the programmers on a particular point.

As I understand it jQuery doesn't seem to only add function or classes contrary to other javascript libraries such as math, for example or even other jQuery plugins like datatables etc...

To me, jQuery at its base just looks like another way of presenting js code.

So to summarise my questions are:

  • Is jQuery a "normal" library like Math for c++, python or even js?
  • How does the js engine understand jQuery? (some sort of compilation ?)
  • Can every js engine understand jQuery as long as they have the jQuery.js file, or is there something already embedded inside the engine for jQuery.

I also took a look at this very interesting so post on Is a jQuery compiler possible?, but it just blurred me the line between library and jQuery even more.

Any hint or link to how js/jquery combine would be helpful!

2

There are 2 answers

3
T.J. Crowder On BEST ANSWER

Is jQuery a "normal" library like Math for c++, python or even js?

Yes. It's just a collection of functions, etc.

How does the js engine understand jQuery? (some sort of compilation ?)

jQuery is just code written in JavaScript using the standard features of the browser (the DOM, etc.). (Well, and some non-standard ones it feature-tests for to get around browser idiosyncracies.)

Can every js engine understand jQuery as long as they have the jQuery.js file, or is there something already embedded inside the engine for jQuery.

jQuery is designed for the browser environment, so it won't work correctly in a non-browser environment without additional dependencies (a DOM library, etc.).


For the avoidance of doubt: There's nothing you can do with jQuery that you can't do without jQuery, using JavaScript's standard library, the DOM API, and other browser APIs directly. All jQuery does is provide an alternate API for doing DOM manipulation, provide some utility functions, and define a standard way to add features to extend jQuery with more functionality (e.g., "jQuery plugins").

And for completeness:

  • jQuery is not a language, although it's a common misconception that it is. You don't do something "in jQuery" or "in JavaScript." The correct contrast is "with jQuery" or "with the DOM" (or "without jQuery").
  • There are other libraries which also fill the same sort of "make the DOM easier" niche, although jQuery is by far the most successful of them.
  • There are entirely different approaches to handling browser-based interfaces, provided by a spectrum of projects from libraries (like KnockoutJS and many others) through light(ish) frameworks (like React and others) to full-on frameworks (like AngularJS and many others).
0
RAHUL S R On

Its pretty simple how you understand a library and a framework when it comes to jquery its a library because it dose'nt add any additional jquery approch whatever you see in jquery is present in javascript what jquery does is shorthand your code and help you chain functions which was not that much possible in javascript and when it comes to plugin they all are also part of javascript functions