1 minute reading

CSS and JS code minification – what is it? How does it speed up website performance?

CSS and JS code minification – what is it? How does it speed up website performance? - Photo 1

code minification

Contents

You are now reading:

CSS and JS code minification – what is it? How does it speed up website performance?

Close

What is code minification?

Minification is a process that aims to reduce the size of source code by removing unnecessary characters.

After minification, all of the following are removed from the code:

  • unnecessary whitespace characters (spaces, enters, etc.),
  • comments (blocks of text covered by /* */ and single-line content preceded by //),
  • sometimes variable/function names are shortened.

Minification reduces code size by several dozen percent. Minified code executes in the same way as before minification, but due to its smaller size, the page loads faster and the browser interpreter operates on smaller amounts of data. As a result of minification, pages download and render faster for users. The minification process typically involves JS (JavaScript) and CSS (stylesheet) code, which are stored in separate files.

But be careful!

Minification modifies the source code and can make subsequent modifications difficult. Always copy a file before minifying. Make any changes to the copied files, and then re-minify the code after making the changes. Best practice is to keep the source files in the appropriate directories on your server, alongside the minified files. If you're doing it yourself, you can use online tools that are fast and free.

(The rest of the article can be found below the form)

Fill out the form and schedule a call with an expert

We'll get to know your business and prepare a personalized quote for the optimal marketing mix. Completely free.

The controller of your personal data is Verseo, a limited liability company with its registered office in Poznań, at ul. Węglowa 1/3.

About Verseo

The Company's registered office is located in Poznań. The Company is entered in the Register of Entrepreneurs maintained by the District Court for Poznań – Nowe Miasto and Wilda in Poznań, 8th Commercial Division of the National Court Register, under KRS number: 0000910174, Tax Identification Number (NIP): 7773257986. You can contact us by mail at the address provided above or by email at: ochronadanych@verseo.pl

You have the right to:

  1. access to your data,
  2. rectification of your data,
  3. request deletion of data,
  4. processing restrictions,
  5. object to the processing of personal data,
  6. transfer of personal data,
  7. withdrawal of consent.

If you believe that we are processing your data contrary to legal requirements, you have the right to lodge a complaint with the supervisory authority – the President of the Personal Data Protection Office.

We process your data for the purpose of:

  1. handling your inquiry, pursuant to Article 6(1)(b) of the General Data Protection Regulation (GDPR);
  2. marketing purposes consisting in the promotion of our goods and services and ourselves in connection with the consent you have granted, pursuant to Article 6(1)(a) of the GDPR;
  3. securing or pursuing possible claims in connection with our legitimate interest, pursuant to Article 6(1)(f) of the GDPR.

Providing your data is voluntary . However, without it, you will not be able to send us a message, and we will not be able to respond to you.

We may transfer your data to trusted recipients:

  1. providers of tools for: website traffic analysis, sending marketing information.
  2. entities responsible for hosting (storing) the website and personal data.

We will process your data for the period of:

  1. necessary to achieve the specific purpose for which they were collected, and after its expiry for the period necessary to secure or pursue any claims
  2. in the case of data processing based on consent until its withdrawal. Withdrawal of consent does not affect the lawfulness of processing prior to withdrawal.

We do not process personal data in a way that would involve making solely automated decisions about you. More information regarding the processing of personal data can be found in our Privacy Policy.

Example of what the page code looks like before minification

CSS and JS code minification – what is it? How does it speed up website performance? - Photo 3
CSS and JS code minification – what is it? How does it speed up website performance? - Photo 4
CSS and JS code minification – what is it? How does it speed up website performance? - Photo 5
CSS and JS code minification – what is it? How does it speed up website performance? - Photo 6
CSS and JS code minification – what is it? How does it speed up website performance? - Photo 7

And this is what the sample page code looks like after minification

CSS and JS code minification – what is it? How does it speed up website performance? - Photo 8

Simpler, right? 🙂 For Google, it certainly is! Page speed affects the positioning of websites in search engines – so proper code minification is an action that improves a website's SEO.

CSS Minification FAQ

Minification is the process of reducing the size of a website's source code. It involves permanently removing all characters from text files that are not necessary for the browser to execute the code correctly. This procedure is most often used for style sheets (CSS) and scripts (JavaScript).

During this process, algorithms clean the code of, among others:

  • unnecessary whitespace characters (spaces, tabs, enters),
  • comments left by programmers (e.g. blocks of text marked with /* */ or //),
  • long variable and function names (which are sometimes shortened).

By removing unnecessary characters, the size of code files can be reduced by several dozen percent. This smaller size means the page loads faster, and the browser interpreter has less data to process. Faster loading and rendering of the website is highly appreciated by Google's crawlers, which directly improves the website's SEO positioning in search results.

Minified code becomes a dense wall of text that is extremely difficult for humans to read and modify. Therefore, you should never work solely on minified files. Best practice is to store the original source files alongside the minified ones on the server. Any changes and corrections should be applied to the readable original, and only then should they be saved should they be minified again.

Summary

The above article covers the following topics:

  • Minification is the process of shrinking source code by removing unnecessary comment characters and shortening variable names. This reduces the size of JS and CSS files by several dozen percent. Minified code works the same way, but the page loads and renders faster, improving SEO and search engine rankings.