Compiling / Minimizing HTML, CSS and class files

3

On the CSS side I already compile and minify the CSS file.

Doubts began to surface when I noticed that some sites work with a type of compile including HTML files. In other cases, such as Facebook, there are several classes with the name well differentiated, looking like it was coded, as in the picture below:

Is this really some kind of class / name encoding? It seemed strange to me, since both the css file and the html file are easily accessible to the client.

But contrary to that, I see some good points in using this. It may give a slightly greater difficulty in understanding the context / purpose of that class, since it would not have such an intuitive name as nav.menu_mobile . Or, leave the source of the project with greater freedom in using the class name without leaving an extensive and exaggerated HTML. For example, you could create classes with names cadastro_cliente , cadastro_cliente_dependente , and in compilation would be just a simple code of 4-5 letters, as in the example.

Would this really be a form of compilation or just an internal convention starting from development?

Another question would be in the compilation part of the HTML file. I already know that it is possible, but I do not know how far this practice is recommended, since in some cases the HTML hierarchy changes the structural behavior (depending on the CSS structure). For example:

<ul>
    <li></li>
    <li></li>
    <li></li>
</ul>

Behave differently from this code:

<ul><li></li><li></li><li></li></ul>

I'm new to major project maintenance. Now I am working on one that is really challenging and great so I would like to know how far I can go with these questions. I know that in terms of performance this may not have such a significant impact that it will be advantageous to spend so much time focusing on this aspect.

But if it's worth it, for the sake of optimization, organization and improvement, I think it's worth it.

    
asked by anonymous 29.11.2015 / 23:41

1 answer

2

I already talked about the minification in another question . It is interesting in elements that change little. HTML usually changes a lot, so it's better to do compression or leave without any gain in size. But there are cases that HTML may change little too. This happens more and more with so-called "application pages" ( SPA ).

What can be done in cases where HTML changes with each call is to minimize the size of some things that change little even when HTML is generated. The HTML generation itself can take care of minifying it.

HTML is all text, so all of it is large and can get smaller, this is done. It can even be done before generating HTML.

It is possible to abstract certain elements in such a way that the specific text that will be used to assemble the HTML is not known to the programmer who is assembling that page. Then it uses something that for it is cadastro_cliente , but what will actually be used in HTML is _2gyi .

Modern programming is to create abstractions to make coding easier and to get a better concrete result. Match the useful to the pleasant.

I do not know if this case can be called a compilation. Looking at the strict definition of the term, I do not think so. But creating HTML is still a compilation of texts coming from several sources. There the term is more literal to what we know outside of computing.

Turning ready-made HTML into another mined HTML is still a compilation, although the term minification would be better in this case.

Obviously, these techniques outweigh traffic on high traffic sites.

In general it is good to minify HTML (static). The minifiers know how far they can go without compromising anything. If you are going to create an algorithm that will set up mined HTML, you have to know all rules to not get past the point.

I do not know of any problem in using the HTML lists in the two forms presented. For me they work the same way. If this is not the case, show this (preferably in another question, it is already too wide).

    
30.11.2015 / 00:10