JavaScript

Definition

What is JavaScript?

JavaScript is a programming language designed to make static websites built with HTML more dynamic and interactive.

If you want a more in-depth understanding of this topic, check out the FAQ section below:

Question #1: What is the difference between JavaScript and HTML?

The biggest difference between JavaScript and HTML, at least in terms of building websites, is their main purpose. HTML is the markup language you use to build the pages and overall structure of websites. JavaScript is the programming language you use to add complex functionality to them.

HTML essentially allows you to build simple online brochures. It turns these online brochures into full-on dynamic experiences that web visitors can actually interact with. It does this by adding things such as:

  • Multimedia
  • Dynamic elements (e.g., colour-changing buttons, carousels, and drop-down menus)
  • Personalisation (using variables)

In addition to this, however, it also serves as a base for a lot of powerful application programming interfaces (APIs) that can significantly boost the functionality of your website, allowing you to do things such as:

  • Take flight and/or hotel bookings
  • Link your (or other people’s) social media accounts to your website
  • Link your (or other people’s) YouTube account to your website
  • Create and manipulate graphics
  • Add video and voice calling functionality

Question #2: What is the difference between JavaScript and HTML5?

The biggest difference between JavaScript and HTML5 is that the former is a programming language while the latter is more of a standard that includes HTML, CSS, JavaScript, and other technologies used to build the modern websites we see today.

At the end of the day, however, the HTML part is still in charge of the structure of websites while the JavaScript part is still in charge of making websites more dynamic and interactive.

Question #3: What is the difference between JavaScript and CSS?

The biggest difference between JavaScript and CSS is their purpose. As we have seen earlier, it’s not only makes websites more dynamic but also adds a host of powerful functionality to them. In contrast, CSS—which is short for cascading style sheets—is used to define their overall look.

Question #4: What can I do with JavaScript?

Aside from making websites more dynamic and interactive, there are a lot of other things you can do with JavaScript, including:

  • Building web and mobile apps
  • Building web servers
  • Developing server apps
  • Developing games

Question #5: What are the benefits when using it?

Aside from what we have seen so far, there are many other benefits to using JavaScript, including:

  1. Speed
  2. Lower server load
  3. Compatibility

Let us go over each one in more detail:

  • First, since JavaScript runs on the client-side instead of the server, it cuts the number of server requests a user’s device has to make, making everything run significantly faster.
  • Second, another benefit of everything being executed on the user’s device instead of the server is that it significantly reduces the load on the server, saving bandwidth as a result.
  • Finally, JavaScript is not only compatible with virtually all modern web browsers, but also works extremely well with other scripts and programming languages.

Question #6: What are the downsides when using it?

Despite its many benefits, there are also a couple of downsides to using JavaScript that you should take note of, including:

  1. Code visibility
  2. Vulnerability

Let us take a closer look at each one:

First, since it is added directly to the code of a website, anyone can easily view, copy, and reuse it, which may or may not be a big deal depending on the type of website you have.

Second, it is quite vulnerable to cross-site scripting (XSS). This means hackers can manipulate your website or web app, injecting malicious code that would run on your user’s devices—often undetected—to do all sorts of questionable things, such as:

  • Stealing information and files
  • Gaining access to private accounts
  • Manipulating and/or destroying files
  • Causing the system to behave weirdly

This is exactly why security-conscious users typically block JavaScript elements on all websites and web apps by default, except for those they know and trust.