What is Minification?
Minification means to minimize code (HTML, CSS, JS) and markup in your web pages and script files.
This reduces load times and bandwidth usage on websites. Moreover, it improves site speed and accessibility. Additionally, a user can access your website even with a limited data plan.
Why Minify HTML?
The primary goal is to remove redundant or unnecessary data such as spacing, well-named variables, and comments. Although developers tend to make the code and markup more readable for others who might work on it later.
But it puts a negative effect when it comes to serving pages. Therefore, anything that makes the HTML readable to developers but is not essential for the compilation that can be modified and eliminated.
When files are minified then, comments, extra-spaces are removed and variable names are crunched to minimize the code and reduce the file size. There is only one downside of this process that the minified file is not readable. So, it is crucial to keep both versions of the file.
Designers and developers can work on the human-readable file whereas the other version is used to deploy to the server.
To distinguish the files from one another, the original resource contains “.html” and the minified version uses “.min.html” file extension.
Sometimes the minimized file size is reduced to 60%.