HomepageExploring JavaScript (ES2024 Edition)
You can support this book: buy it or donate
(Ad, please don’t block.)

48 Next steps: overview of web development

You now know most of the JavaScript language. This chapter gives an overview of web development and describes next steps. It answers questions such as:

48.1 Tips against feeling overwhelmed

Web development has become a vast field: Between JavaScript, web browsers, server-side JavaScript, JavaScript libraries, and JavaScript tools, there is a lot to know. Additionally, everything is always changing: some things go out of style, new things are invented, etc.

How can you avoid feeling overwhelmed when faced with this constantly changing vastness of knowledge?

Icon “tip”Trust in your ability to learn on demand

It is commendable to learn something out of pure curiosity. But I’m wary of trying to learn everything and spreading oneself too thin. That also induces an anxiety of not knowing enough (because you never will). Instead, trust in your ability to learn things on demand!

48.2 Things worth learning for web development

These are a few things worth learning for web development:

One good resource for learning web development – including JavaScript – is MDN web docs.

48.2.1 Keep an eye on WebAssembly (Wasm)!

WebAssembly is a universal virtual machine that is built into most JavaScript engines. We often get the following distribution of work:

For static code, WebAssembly is quite fast: C/C++ code, compiled to WebAssembly, is about 50% as fast as the same code, compiled to native (source). Use cases include support for new video formats, machine learning, gaming, etc. It helps that it is relatively easy to compile existing code bases (e.g. ones written in C) to WebAssembly.

WebAssembly works well as a compilation target for various languages. Does this mean JavaScript will be compiled to WebAssembly or replaced by another language?

48.2.1.1 Will JavaScript be compiled to WebAssembly?

JavaScript engines perform many optimizations for JavaScript’s highly dynamic features. If we wanted to compile JavaScript to WebAssembly, we’d have to implement these optimizations on top of WebAssembly. The result would be slower than current engines and have a similar code base. Therefore, we wouldn’t gain anything.

48.2.1.2 Will JavaScript be replaced by another language?

Does WebAssembly mean that JavaScript is about to be replaced by another language? WebAssembly does make it easier to support languages other than JavaScript in web browsers. But those languages face several challenges on that platform:

For dynamic code, JavaScript is comparatively fast. Therefore, for the foreseeable future, it will probably remain the most popular choice for high-level code. For low-level code, compiling more static languages (such as Rust) to WebAssembly is an intriguing option.

Given that it is just a virtual machine, there are not that many practically relevant things to learn about WebAssembly. But it is worth keeping an eye on its evolving role in web development. It is also becoming popular as a stand-alone virtual machine:

48.3 An overview of JavaScript tools

In this section, we take a look at:

The former are much more important. The names change, as tools come into and out of style, but I wanted you to see at least some of them.

48.3.1 Building: getting from the JavaScript we write to the JavaScript we deploy

Building JavaScript means getting from the JavaScript we write to the JavaScript we deploy. The following tools are often involved in this process.

48.3.1.1 Transpilers

A transpiler is a compiler that compiles source code to source code. Two transpilers that are popular in the JavaScript community are:

48.3.1.2 Minification

Minification means compiling JavaScript to equivalent, smaller (as in fewer characters) JavaScript. It does so by renaming variables, removing comments, removing whitespace, etc.

For example, given the following input:

let numberOfOccurrences = 5;
if (Math.random()) {
  // Math.random() is not zero
  numberOfOccurrences++
}

A minifier might produce:

let a=5;Math.random()&&a++;

Bundlers (see below) usually support minification.

48.3.1.3 Bundlers

Bundlers compile and optimize the code of a JavaScript app. The input of a bundler is many files – all of the app’s code plus the libraries it uses. A bundler combines these input files to produce fewer output files (which tends to improve performance).

A bundler minimizes the size of its output via techniques such as tree-shaking. Tree-shaking is a form of dead code elimination: only those module exports are put in the output that are imported somewhere (across all code, while considering transitive imports).

It is also common to perform compilation steps such as transpiling and minification while bundling.

Popular bundlers include:

48.3.1.4 Task runners

Sometimes there are build tasks that involve multiple tools or invoke tools with specific arguments. Task runners (in the tradition of Unix make) let us define simpler names for such tasks and often also help with connecting tools and processing files. There are:

48.3.2 Static checking

Static checking means analyzing source code statically (without running it). It can be used to detect a variety of problems. Tools include:

48.3.3 Testing

JavaScript has many testing frameworks – for example:

48.3.4 Package managers

The most popular package manager for JavaScript is npm. It started as a package manager for Node.js but has since also become dominant for client-side web development and tools of any kind.

The following alternatives to npm use npm’s package registry (think online database):

Additionally, there is JSR (JavaScript Registry):

48.3.5 Libraries

Given that JavaScript is just one of several kinds of artifacts involved in web development, more tools exist. These are but a few examples: