Build step obsession

Welder with face covered crafting with a tool that sparks

For I desired mercy, and not sacrifice; and the knowledge of God more than burnt offerings.

Hosea 6:6, The Bible

Building websites today has become easier than it's ever been. All you need is a text editor and a browser, two programs that almost every home computer possesses today (and most times, right out the box).

To make your first webpage, you can create an index.html file anywhere on your computer, stuff it with the following content, and open the file in a browser:

<h1>Hello, world</h1>

And voila! You've made your first webpage. Slap on a domain name and throw it on a hosting service and you are good to go.

So why do we need build steps on the web?

That question reminds me of a story in the Bible.

Starving on the Sabbath

Jesus was walking through a field of corn with his disciples one Sabbath day. His disciples were hungry, so they plucked ears of corn from the field and ate them. The Pharisees saw them and told Jesus that his disciples are doing what is unlawful on the Sabbath.

What was Jesus' response?

And he said unto them, The sabbath was made for man, and not man for the sabbath:

Mark 2:27, The Bible

Huh? What was Jesus saying?

Jesus was telling the Pharisees that God created the Sabbath to serve man (by giving him rest) and not so that man serves the Sabbath. In other words, instead of focusing on the work others are doing, rest (like God did on the seventh day of creation).

In this analogy, sabbath can be replaced with web. The web was made for man, and not man for the web.

But today, with so many tools on the web, web developers tend to focus on work (i.e. build steps) and tend to do more work than necessary.

Why are build steps bad?

When I say build step, I mean any step that needs to be performed before deploying your website.

As innocuous as it sounds, choosing the wrong build steps can affect 3 areas every web developer should care about:

Let's explore some popular build steps on the web and measure how each listed area is affected.

The transpilation build step

This involves converting JSX, TSX, TypeScript, SCSS, SASS, Svelte templating language etc. into HTML that browsers can render.

Advantages

Disadvantages

The minification build step

This step involves removing all the unneeded white space and sometimes obfuscating the data in a CSS or JS file to reduce the size of the data that is sent to the browser.

This sounds like a wonderful idea.

Advantages

Disadvantages

Could be wrong on this one; it seems like the advantages are more here. ๐Ÿ˜’

The Webpack build step

Webpack is a powerful tool used to bundle modules together. A module is any file that processed by Webpack. In the case of Webpack, we're talking HTML files, CSS files, JavaScript files, images etc.

NOTE: This also includes running npm run build.

Advantages

Disadvantages

Am I the only one that notices that half of the advantages are solutions to the problems caused by Webpack itself? Maybe it's just me. ๐Ÿ˜’

The SSG build step

According to ChatGPT:

An SSG stands for Static Site Generator. It is a tool that generates static HTML pages from source files, usually using templates and content written in a markup language like Markdown. SSGs are widely used in web development for creating fast, secure, and SEO-friendly websites.

Advantages

Disadvantages

The SSR build step

Once again, educate us ChatGPT:

Server-Side Rendering (SSR) is a web development technique where the server generates the full HTML for a web page and sends it to the client (usually a browser) in response to a request.

Did you catch the fallacy? Rendering only happens at the browser, not on the server. Server-side rendering is really a myth.

The server's job is to serve HTML, not to render it. But I digress ๐Ÿ˜’.

Advantages

Disadvantages

Maybe we should stick to servers serving HTML and not rendering it. ๐Ÿค”

So what is the ideal process?

The ideal process is no build steps! That's it! You just need to run your code in the browser.

To host your code online, just copy it from your computer to the server. It should be that simple.

Why is rest important?

Jesus wanted to do all the work for us and wanted us to rest. The same is true for the web.

Tim Burners-Lee (TBL) made the web simple so that everybody can contribute. When you make things harder for people to do, you are working against the principles of the web.

It is only in rest that you can fully appreciate what TBL and contributors to the web have done. It allows you to focus on real problems on the web, and not the many build steps that don't improve the quality of what is delivered.

The bottom line

Ditch the build steps. ๐Ÿ› ๏ธโŒ Become familiar and well-acquainted with HTML, CSS and JS. Unlike all the web frameworks and fanciful build steps, those languages are not going anywhere.

Further reading

If you would like to reply to or comment on this blog post, feel free to email me at efe@mmhq.me.