Home / Fr 🇫🇷 | En 🇬🇧 / Documentations En / Gmod Base / The minificaytion (Optimisation)

The minificaytion (Optimisation)

🇫🇷 🇬🇧

imgNorda Creator of this doc
Document Updated ago
Some people think they are geniuses when they criticize the indentation of a code but they don't know the term: Minification...

Minification is not "ugly bad code". Code is not just made to look good, but to provide a service that works.

Now let's be precise, I made this choice to reduce the size of the files. Smaller files take less space in the cache usually stored in the memory, and downloaded by the client at his connection, so a choice that impacts the loading time because less large file to download for your users, choice that I also apply here on this site and that pays in performance. Test this site on google speed for example in comparison with another one which is a reference for you, you will understand what I am talking about.

The beauty of a code takes space, it allows a team to work on the same code and this team to see clearly. It allows a better organization.

Here, you have to realize that I code alone and that my code is primarily intended for the machine. So if you don't see the indentation it's because I'm minifying my code.

Minification is a form of web optimization recommended by Google to reduce the loading time of sites to the maximum and to the bare minimum necessary to function. I explain in detail in this documentation here, why and what it is used for.

To give an example of comparison, my finished gamemode is more optimized than a lambda administration system alone. Thanks to the complete minification of the source code. Yet it is extremely complete and also contains an administration system within its source code.

In web a not minified code is in my opinion a not finished code.

Servers suffer a lot from loads when there are a lot of scripts, users take a long time to reach a server and sometimes get discouraged before the end of the load and leave, reducing this time could prevent them from leaving before the end of the load by reducing it as much as possible, this method applied to all your scripts is not to be neglected.



In programming, minification means to reduce the size of the code to reduce the size of a program to download from a server and thus reduce network congestion, on Gmod the size of a Lua file on the client side if it is minified it will be faster to download. There are a lot of optimization rules, minimization is one of them.

To do this, we remove all unnecessary comments and characters that will not interfere with the proper functioning of the application. The name of the application's internal variables is also replaced to reduce them to one or two characters. It is also possible to use some compact writings specific to the languages (color in hexadecimal, shortcuts...).
This process is widely used in web programming.

Exemple 1: Code not minified
Code not minified
local function my_supermegahyper_test ( Player , Argument , NUMBER )

local firstnumber = NUMBER[1] ;
return firstnumber * 2;
end
concommand.Add( "give_me_double" , my_supermegahyper_test )



Exemple 2: Code minified
Code minified
local function test(a,b,c)return c[1]*2 end

concommand.Add("give_dbl",test)

Applying minification to an entire program gives a result that is not negligible.
This method is used to reduce the downloading time in many languages, when you work in a team it is important to take stock so you don't get lost in the limbo of minification.

This documentation provides a single optimization element on several criteria:
How to reduce the loading time of my users on my Gmod / DarkRP server?
- Reduce the number of workshop resources to the bare minimum necessary for your project, do not upload unnecessary and superfluous content.-
- MINIMIZE YOUR SCRIPTS!!!
- Do not overload your maps with poorly optimized entities.