In the process of developing a website or web application, the code file can become large. The reasons for this could be a result of the type of project and dependencies, framework bundles, and so on.
When a project becomes large, load time is impacted, which then affects the performance of the website or application.
This is why the concept in web development called minification exists. Minification involves reducing the size of code files by removing unnecessary characters to improve website performance.
We’ll be elaborating on this concept in this article, understanding how it affects the functionality of a website and so on.
What is Minification?
Minification as a course of action involves the reduction of code and markup in a web page or script file.
This practice is used in web development and helps to reduce bandwidth usage on websites or applications, which is beneficial to users, especially those with a limited data plan.
The process of minification entails the removal of unnecessary codes or characters from files to reduce their size. Minification is related to HTML, CSS and JavaScript files, and performs the following:
Remove whitespaces and newlines
Remove block
Remove comments
Giving short names for variables and functions
This way, the file loads easily in the browser, which increases load time. There are many reasons why developers use a minification tool. For instance, using a minification tool;
Test how minification can affect code size
Prepare code for the production environment
Promote better workflow practices
Prevent code tampering (however, note that other security practices must also be implemented as well))
Minification is used in:
Frontend Build Tools: Webpack Gulp, and Parcel, are tools designed to simplify the process of minifying HTML, CSS and JavaScript files.
Webpack: Webpack is a module bundler for JavaScript applications that can compile and bundle assets into single or multiple output files.
Gulp: Gulp is a toolkit to automate slow and repetitive tasks such as bundling and minifying libraries and stylesheets, running code analysis, and much more.
Parcel: Parcel is a zero-configuration build tool for the web, designed to automate, build, bundle, and optimise web applications. It offers minification for JavaScript and CSS when you build using parcel build. It also includes image resizing, optimization, and much more.
Content Delivery Networks (CDNs): CDNs are a system of distributed servers that work together to deliver web content to users based on their geographical location. They can also provide minified versions of website assets.
If we are familiar with using libraries, we may have seen that many libraries use min.js or min.css suffix
Example - This CDN link to the minified file of font-awesome has the suffix min.css,
https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css
which means that the files have been compressed to optimise performance. Some CDNs are optimised for production, which you can use in your applications.
Application Programming Interface (API) response: API responses can be minified to save bandwidth; for instance, a library called json-minify can be used to minify json-response. Also, some API services provide built-in responses for minification.
Here’s an example of a file that has been minified and one that hasn’t been. This example shows the URL which is a bootstrap JavaScript file. It is hosted on jsDelivr, a content delivery network that helps in including the bootstrap framework into a project for layout and styling.
The above image is what it looks like when it is minified, and if we look at the URL you’ll see the .min suffix.
If we take a look at the above image that shows the URL without the .min suffix, we can see that the predefined JavaScript functions have more space between them. Now that you've seen the difference between a normal and minified file, let’s go through some benefits of minification.






