TOC

This article is currently in the process of being translated into Vietnamese (~13% done).

About JavaScript:

JavaScript libraries

I just promised that this tutorial would concentrate on the core JavaScript experience first, and only later discuss the web-related parts of it, but I do want to mention one subject which relates to the web before we get started: JavaScript libraries.

JavaScript is a highly extensible language, so it's very easy for you to add your own functionality to the language and use it as if it was a natural part of JavaScript. Quickly after the introduction of JavaScript, skilled developers took advantage of this fact and started to build their own libraries. These libraries would add the functionality they used a lot, or made existing functionality a lot easier to use - a kind of shortcuts to do things easier and with fewer lines of code.

One of the main reasons for developers to start adding these shortcuts was the fact that, back in the old days, especially during the browser wars, the various browsers had their own, custom JavaScript engines. This meant that while MOST of the functionality was the same across the most popular browsers, there were small differences, basically meaning that you couldn't rely everything to work the same way for all your website visitors.

So, a lot of the initial libraries were basically just functions that would check which browser the visitor was using and then work around whatever issue or shortcoming this browser might have, to ensure that everything worked as intended, no matter what.

Most developers would just keep their libraries to themselves, or within the company they worked for, but some libraries were released to the public, usually because they added functionality that was deemed important to a lot of developers. The release of these libraries allowed other developers to chip in and add even more functionality, while perfecting the existing.

jQuery

Một trong số những thư viện Javascript đầu tiên được sử dụng phố biến là jQuery. Nó được phát hành vào năm 2006 và nó phần lớn khiến việc tìm kiếm và chi phối các phần tử trong DOM (Document Object Model - Mô hình Đối tượng Tài liệu), tức là, trong một trang web, là tất cả các phần tử cấu thành nên bố cục và nội dung. Nó đồng thời đảm bảo tất cả chức năng liên quan đến web hoạt động ở mọi trình duyệt web như dự kiến.

During the following years, jQuery received continuos updates, allowing the end users to do more and more. Examples of this is AJAX requests, animations and a heap of utility functions, basically just making it easier for the developers to accomplish simple and advanced things with few lines of code.

Of course, the success of jQuery spawned a LOT of competing libraries. One of the first ones was mooTools, which was released in 2007, but this was just the tip of the iceberg: While jQuery kept growing the amount of functionality, other developers insisted on releasing slimmer alternatives to keep the size and complexity to a minimum, or libraries which simply did things completely different.

jQuery usage: Now and in the future

Today, jQuery is considered outdated by some developers. They feel that it tries to do too much, and some of the problems it originally solved is no longer an issue, thanks to the development of JavaScript and the consolidation of JavaScript engines. However, according to Wikipedia, "As of Aug 2022, jQuery is used by 77% of the 10 million most popular websites".

So, there are definitely many alternatives to jQuery, and one of them is simply to NOT use a JavaScript library, but simply rely on the core JavaScript engine, which today is MUCH better than it was in 2006 when jQuery was released. However, for beginners, jQuery is a fine starting point. It makes things a lot easier, allowing you to focus on the fun tasks of creating dynamic websites, while leaving the boring and tedious parts to jQuery.

Summary

JavaScript libraries makes it easier to develop dynamic websites, and while they were definitely more necessary 15 years ago than today, you should still consider giving them a try if/when you dig into writing JavaScript for the web.


This article has been fully translated into the following languages: Is your preferred language not on the list? Click here to help us translate this article into your language!