What are the advantages and disadvantages of minifying JavaScript scripts?


And what minifiers can I use?



The gain is pretty obvious, the file gets smaller and loads faster. Some will say that it's harder to read the code and be reused, but I don't think this is a real advantage and there are better techniques.


There is no real downside. Of course if you're still developing you need to debug you won't use the minified version. The most that can be said is that there is an extra step to do the minification, but this can be automated and is not really a disadvantage. Some may find other disadvantages exoteric but we are talking about real situations. Obviously using an aggressive and insecure minifier is not a good idea so it is quite disadvantageous.

Is it really useful?

It applies to all text files that have redundant characters used only for human readability. In dynamically generated content, the application of this technique does not usually compensate for the time the server will spend to minify each result sent.

This technique can be used together with the data compression technique. Don't confuse the two, minifying is not the same thing as compressing.

Some might wonder if compression isn't a much better technique and would even dispense with minification. This is true but not all clients support compression and then you are left without any technique. Any customer who understands web standards well understands the minified file. The gain may not be fabulous but it is important.

best minifiers

Any minifier minimally (I didn't miss the opportunity 🙂 ) well done will get a reasonable result, unless it's a very naive one and made by someone who doesn't know what they're doing (then you have even bigger problems), you'll have a gain Good. I doubt there is much difference between the most diverse. Do a real assessment using some of them and see which works best for you.

I would avoid using a stranger, no one knows if he is trustworthy. The worst thing you can do is use a minifier that breaks your code.

Some well-tested acquaintances:

Some of these are for CSS too. Below are some for CSS that can also work with JS.

And obviously you can minify HTML (when it rarely pays off):

Test them with your stuff and see which one works best. Don't expect big differences.

Scroll to Top