Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does JS minification convert 1000 to 1E3?

What is the point to change (int) 1000 to 1E3?

And where does 1E3 come from?

I know just 3bytes vs 4bytes.

like image 708
l2aelba Avatar asked Sep 03 '14 13:09

l2aelba


People also ask

What does 1E3 mean?

1E3 is notation for the mathematical expression 10^3 which is the same as 1000. If you wrote a million 1E6 would be 1000000 and then you would save two more bytes.

Why would a website minify their source code?

Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used to reduce load times and bandwidth usage on websites. Minification dramatically improves site speed and accessibility, directly translating into a better user experience.

How does JavaScript Minification work?

How Minification Works. Minification works by analyzing and rewriting the text-based parts of a website to reduce its overall file size. Minification extends to scripts, style sheets, and other components that the web browser uses to render the site. Minification is performed on the web server before a response is sent ...

Should you minify JavaScript?

It is important to minify your CSS and minimise JavaScript files so they can load faster on your web pages. There are many reasons why you should minify your CSS and JavaScript: Reduce file size: The more code there is in a file, the larger it will be. Minified code is usually much smaller than the original version.


1 Answers

The whole point of minification is to be able to pass less data over the network but retain the same functionality.

Taken from wikipedia:

Minification (also minimisation or minimization), in computer programming languages and especially JavaScript, is the process of removing all unnecessary characters from source code without changing its functionality. These unnecessary characters usually include white space characters, new line characters, comments, and sometimes block delimiters, which are used to add readability to the code but are not required for it to execute.

As long as the size is smaller the minification is doing its job.

1E3 pretty much means 10 to the power of 3; a shorter way of representing the number 1000.

like image 79
Lix Avatar answered Sep 25 '22 17:09

Lix