How does minification handle $scope.obj.subObj = { key: val ...};
from what I understand the last to use variable stays unchanged,
but if I were to have html element
<div>{{obj.subObj.key}}</div>
would the result of minify shorten the code to a.b.c.key? forgive me for asking in amateur fashion, but I'm trying to understand how javascript minification works.
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 ...
Uglification improves performance while reducing readability. Encryption: This is the process of translating data, called plain data, into encoded data. This encrypted, or encoded, data is known as ciphertext, and needs a secret key in order to decrypt it.
Minification: In minification process following things are done within the js file to reduce the size of the js file for faster downloading. It removes all the white spaces within the file. It removes all the unwanted variables within the file. It converts all the big variable names to the smaller variable names.
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.
From: http://en.wikipedia.org/wiki/Minification_(programming)
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.
So, if the minifier is able to detect that it can safely rewrite $scope.obj.subObj
to a.b.c
it will.
As a rule of thumb though, any variable that is from the global scope, like document
, window
or jQuery
will not be minified because other code (outside of the scope of this file) might depend on it.
The next step up from minifying is using a compressor like Google Closure Compiler or Yahoo's YUI Compressor. These programs are typically more powerful minifiers. They can replace a function call by an in-line function for instance or change a certain method by a shorter or faster method. This requires a lot of knowledge about JavaScript and performance optimizations.
You can crank up the compression rate by dropping certain compatibility requirements but I've found the resulting code to be very unstable so I don't think we're quite there yet :)
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