Habilelabs-Logo
Blog

What is Minification and It’s Benefits

July 11th, 2017 . 3 minutes read
Blog featured image

Do you know What is Minification and why do we minify our code? if you want to know then you are in the right place. let’s discuss.

When you write code, the code can grow big in size. It can contain thousands of lines thus making the page size bigger. Bigger page sizes lead to large page load time which may disrupt your website performance. Moreover, it can cause relatively large bandwidth consumption, increasing costs which is not good for business.

With minified code, the page size gets reduced so that when the browser loads your code, it can load fast, and makes your website loading faster.

It reduces bandwidth consumption and other resource usages thus minimizing the cost and maximizing the performance.

What is Minification?

Minification is basically the removal of unnecessary code that the browser doesn’t need. It is done by minimizing the code and making it compact.

For example, when you open a website and see its source, often you will find code written like this-

This really doesn’t mean that the programmers have written it this way. This representation is only for the browser.

When you write code it contains lots of white-spaces, comments, big variable names, etc which are completely unnecessary for the browser, i.e. it ignores it. These things are just for programmers for readability and re-usability. So, what minification means is to remove these unnecessary things from your code that are of no meaning to the browser.

Let’s take an example:

Un-minified code- Size: 756 bytes gzipped (2.72KB uncompressed)

 

minified code: – Size: 482 bytes gzipped (1.55KB uncompressed)

Saved 36.24% off the gzipped size (43.09% without gzip)

How to minify your code:-

Well, you can do it your own self, but this will certainly be a very bad choice. You can use the following tools that are available for free:-

Links to follow for Code Minifier tools:

You can use these tools to minify code easily.

Moreover, when you download a 3rd party library such as jQuery etc you have the choice to download the minified version
for production or the full version for development, though they will be functionally identical.
If you choose npm or browser to use those libraries, they will come to you as minified.

Conclusion:-

To conclude minification is a technique by which you can reduce resource usage, reduce page load time and increase the
performance gain making the user experience better.

We are web development experts, we also develop the best quality mobile applications.

Ask anything in the comment section if you have any queries or suggestions.

Author: sankalp
Share: