I'm writing an app using Enyo2 which comes with a minification tool based on UglifyJS. I've noticed that:
var t = false
is replaced with
var t=!1
The same way true is replaced with !0. I'm sure there is a good explanation for that, I just can't find it. Any idea?
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 ...
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.
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.
Minification is just removing unnecesary whitespace and redundant / optional tokens like curlys and semicolons, and can be reversed by using a linter. Uglification is the act of transforming the code into an "unreadable" form, that is, renaming variables/functions to hide the original intent...
There is one apparently. If you use 1 or 0 to translate true or false, it would be shorter but seen as integers. If you add ! in front and reverse them, it will be coalesced into booleans and still be short.
It is the smallest non-ambiguous way to express the value.
true
uses 4 characters on the wire and false
uses 5 characters. !1
& !0
use 2 characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With