Why Do You Need to Learn Javascript?

Although JavaScript is not one of the hot and trendy programming languages, it’s one of the most widely used “granddaddy” technologies of the Internet. In fact, according to StackOverflow, web developers (both front and back end) are more likely to use JavaScript than any other language — in the U.S. nearly 95% of websites use it.

A History Lesson

To understand why JavaScript dominates the modern internet, look at some of its history. When you look at a web page today, your browser is typically looking at three technologies: HTML, CSS, and JavaScript.

Hypertext Markup Language (HTML) is the text, which contains content, paragraphs, headers, and more. Essentially, HTML is the skeleton of a web page, providing structure. Cascading Style Sheets (CSS) represent the visual style of a web page. CSS handles specifics like color, position, fonts, sizes, and more — it’s the visual side of the Internet. The final technology of the “big three” is JavaScript. JavaScript is the animation that brings web pages to life — without it, the Internet is motionless. Nowadays, JavaScript handles any dynamic logic a web page has. It’s the de facto front-end scripting language that developers use to write client-side code.

By 2005, the Internet was headed in a new direction. Up until this point, websites for the most part were static. Then web applications like YouTube and Facebook arrived on the scene (to name just two), bringing new capabilities with them, including video, and real-time user-driven content. Web destinations were distinctly different from the static websites used in the '90s. At that time, applications predominantly used HTML and CSS, but not much (if any) JavaScript.

During this time, a new way of using JavaScript started growing in popularity. Asynchronous JavaScript and XML (AJAX), known previously as “that xml http thing,” were a developer’s dream. They were a set of techniques that allowed developers to update data being displayed on a web page without having to reload the entire page, request data after pages had loaded, and quietly send data in the background. Everything dynamic about the Internet can be laid at the feet of AJAX. For example, AJAX is used to:

  • Power search engine autocomplete
  • Create the infinite scroll of your Facebook wall
  • Offer real-time pagination
  • Support for single-page web applications
  • Implement real-time address verification
  • Create in-browser chat windows

In addition, developers can create loading screens, real-time voting and rating, sorting, filtering, and form validation. Everyone wanted more dynamic, interactive web applications, and AJAX allowed developers to create them.

Looking Ahead

If that isn’t enough to convince aspiring or working web developers to brush up on their JavaScript, then the future of the language should. As mobile devices and the Internet of Things (IoT) have become more prevalent, so too has the need for front-end frameworks. There are some relatively new developments in JavaScript, such as React, an open-source JavaScript library for building user interfaces [see also Why We Built Our New Developer UI on React Instead of Angular]. Another example is AngularJS [see also What is the Angular Framework and Why Should Developers Use It?], a JavaScript-based, open source, front-end web application framework, which has huge growth potential.

The rise of front-end frameworks involves a huge amount of logic migrating from the server to the end user’s browser, which many think of as the client side. If developers have one server, and 10,000 connected clients, any logic they give to the clients is distributed to all of their machines. This can give developers huge scalability gains. In addition, instead of making one server do 10,000 extra operations, developers instead make 10,000 connected clients do one extra operation.

Front-end frameworks like Angular and React take the concepts of AJAX and build larger toolkits around it. This approach makes building enterprise-level web applications with sprawling code bases easier. Instead of the server building complete HTML pages and sending them out, the server’s responsibilities are simplified dramatically because it only sends data. A framework like Angular can then grab that data and dynamically present it on the browser. By decoupling the server and the browser in this way, developers can use that same server to handle their mobile apps as well. Think about it like this: if the server only sends data, and not HTML, then the receiving client can be anything — a browser, an iOS device, even technologies like Amazon’s Alexa.

These changes are not without their downsides, however. The increase of code sent to the front end means that browsers are doing more work than ever. In a sense, the burden of performance is being passed to the consumer. This might not be so bad, as many computers are perfectly capable of handling a little extra JavaScript; however, more and more users are browsing the internet on a mobile device. Mobile devices, especially smartphones, will have a harder time running the large, complex codebases that Angular and React provide simply because they have smaller processors. Thanks to improvements in both the local processing power of mobile devices and the improved performance of today’s wireless networks, the ability to accommodate frameworks like React and Angular is improving. In addition to these developments, users can easily tell their browsers not to run any JavaScript.

If a company’s website is completely built around Angular, a user might not understand why a web page isn’t working, which could alienate them. Companies would need to have a complete, but non-JavaScript version of their site to serve to these users, hidden within special ‘no-script’ tags that only become active when a user disables JavaScript. This, of course, costs valuable development time. Finally, the client side is less secure. When a server sends JavaScript to a browser, the code is revealed. This opens the possibility of malicious behavior, and requires careful use of strong JavaScript conventions to keep that code defensible. Luckily, many of these large frameworks are built with security concerns in mind and provide a way to write sensitive client-side code. While the practice is very dangerous, Angular can completely block vanilla JavaScript, for example.

Furthermore, Web Assembly, the first real alternative to JavaScript, is slowly gaining momentum. It will bring a precompiled language to the browser for the first time, eliminating the need to interpret code in real time. Traditionally, a language like JavaScript is interpreted and compiled as you use it. By compiling ahead of time, you save computing power. Pages load faster, and scripts are ready to run more quickly. You can even precompile existing JavaScript with Web Assembly. This step means even if Web Assembly takes the place of the main scripting language of the web, legacy JavaScript libraries will need support for many years to come, cementing JavaScript as a must-learn for any web developer.

Despite some potential downsides, JavaScript is here to stay. The upsides of Angular and React greatly outweigh the downsides, and over the next few years, the two products will continue to grow in popularity.

As a coding bootcamp instructor, I encourage all of my students to learn JavaScript because of its popularity and widespread usage. If you master it, your chances of becoming a successful developer substantially increase.

Brendan Stanton As a Lead Instructor at the Coding Dojo, Brendan loves helping people pick up technology. Originally self-taught, he came to the Coding Dojo to immerse himself in an environment of learning while helping others take those first steps on their coding journey. Besides leading classes and refining course curriculum, Brendan is a huge proponent of the importance of algorithms and is a self-described JavaScript apologist. On the rare occasion he's away from technology and code, Brendan enjoy cooking for people who love food.