Continuing the theme of programming languages and frameworks, let’s talk about one of the most prominent and popular languages: jQuery. Well, technically jQuery is a JavaScript library. A library is a collection of prewritten code snippets, such as functions, that can be used to perform tasks more efficiently within your project.
jQuery was created in 2006 by John Resig with the sole intention of streamlining and simplifying the task of writing JavaScript. As stated before, jQuery is simply a JavaScript library and not its own separate language. The fundamental difference between the two is simply the syntax. jQuery allows developers to reach the same result with shorter, cleaner code. An important note is that all jQuery is JavaScript but it does not contain all JavaScript code within the library but simply the most commonly used functions, but in the end is interpreted as JavaScript by the browser.
Here is an example of jQuery and JavaScript code. Keep in mind that these lines of code achieve the same result.
JavaScript
- querySelector(“example-class”);
jQuery
- $(“example-class”);
As you can see jQuery simplifies code and makes typing out repetitive functions much quicker while still accomplishing the same goal.
jQuery can be imported into any HTML file by including a script tag in your header, which will be accessed via a CDN (content distribution network).