← All blog posts

HTML Minifier vs doing it by hand — which is faster?

WhiteUI · A plain-English guide to the HTML Minifier

For a three-line snippet, deleting the extra spaces by hand feels fast enough. For a full page, the HTML Minifier is faster and far less likely to slip. The honest answer is to use your hands for a quick tidy and the tool for the real thing, and the comparison below shows why, with the actual character counts.

At a glance

20-product page: 19% smaller329 bytes removed1,415 bytes kept1,744 bytes in, 1,415 bytes out
A shop page with twenty products goes from 1,744 bytes to 1,415 bytes. The 329 bytes removed are the indentation and line breaks of twenty repeated blocks.

By hand: counting what has to go

Take the typical small page: 291 bytes as written, 198 bytes minified, so 93 characters have to be deleted by hand. That is the comment in the head, which is 19 characters on its own, plus every line break, every indent, and the extra spaces inside the heading. Each deletion is a small action: find the character, select it, delete it, and check you took the right one. At two seconds a deletion, 93 deletions take 186 seconds, which is just over three minutes, for one small page.

By hand: the slow cases

Now try the shop page with twenty products. It is 1,744 bytes as written and 1,415 bytes minified, so 329 characters have to go, spread across twenty repeated blocks that all look alike. At two seconds a deletion, that is 658 seconds, or about eleven minutes, of careful deleting, and the twentieth block looks exactly like the first, so it is easy to lose your place. With the tool you paste the page in and read the result at once: 329 bytes saved, 19% smaller, with the maths already done for you.

By hand: the risky cases

Speed is not the only difference. Deleting by hand can also break the page. The tool removes a comment and leaves the words on either side exactly as they were, but a person deleting a comment between two words can easily take the space with it, turning Hello world into Helloworld. And inside a pre block, a person has to remember which spaces are layout and which are content, while the tool simply collapses all of them, which is why you check pre blocks either way. A single slipped deletion can cost more time to find than the whole minifying job saved.

When doing it by hand is fine

Hand-minifying is fine when the page is tiny and the saving is small. The already-tight snippet in the worked examples is 37 bytes as written and 31 bytes minified, so only 6 characters have to go, which takes seconds by hand and is easy to check. If you only need to clean up one paragraph, such as <p>Hello world, this is a test.</p>, the 14 extra spaces are visible at a glance, and deleting them by hand takes less time than opening the tool. The dividing line is simple: if the page has more than a few dozen characters to remove, paste it in.

The common mistake

People minify by hand, miss a comment hidden in the head of the page, and then wonder why their file is still bigger than the tool’s version. A comment such as <!-- page title --> is 19 characters, and it is easy to read past it because it looks like part of the page. The tool never misses a comment: it removes every one, every time. If your hand-minified file is bigger than the tool’s answer for the same page, the difference is almost always a comment or a line break you walked past.

Frequently asked questions

Is it faster to minify with the tool or by hand?

With the tool for anything over a snippet. A small page needs 93 characters deleted by hand, which takes just over three minutes at two seconds a deletion.

How long would the 20-product page take by hand?

About eleven minutes: 329 characters to delete, at two seconds each, against a paste-and-read with the tool.

What can go wrong minifying by hand?

You can delete a space between two words and join them, or miss a comment in the head, such as the 19-character page title comment.

When is minifying by hand fine?

When the page is tiny. A 37-byte snippet needs only 6 characters removed, which takes seconds by hand and is easy to check.

More guides on the HTML Minifier

Try it yourself

Try the HTML Minifier — free, in your browser.

Open the HTML Minifier