Javascript Minify

Frequently Asked Questions



Why are there Javascript errors once the code has been minified?

JSMinify only reduces spaces and redundant line changes in the javascript code, which is why it is extremely important for developers to pay special attention, when creating code, to the existence of a semicolon at the end of their expressions and employ grouping operators correctly the grouping operators.

For example, if you write the following code:

a+ ++b

The result of minifying this code would be


which would give an erroneous result, produced by the precedence of mathematics operators. In cases like this one, the correct way to write the code is as follows:

a+ (++b)

Why is the resulting code smaller in other minifyers?

When using JSMinify, the names of the variables are not transformed, and neither are those of the functions, unlike in other javascript minifyers. This way developers can clean up their code easily, once javascript file has been reduced.

Besides, JSMinify adds some missing semicolons to the javascript code as a protective measure for the developers themselves.

Let's see the following example:

a = {}
b = {}

This code has a correct javascript syntax, even if it does not have a functional sense.

When using other minifyers, the result is:

a={}b={} which shows a syntactic error in the javascript, announcing that a semicolon is missing before b=

Using JSMinify, the result will be a bit different:

a={};b={} which is syntactically correct.