D
D
del9937882016-04-02 15:49:19
css
del993788, 2016-04-02 15:49:19

Are there such code optimizers?

Hello. I had such a situation. I have 2 colors for text on my site. Half of the words are in black, the other half are in pink. And in order not to write in color:#f68 styles every time, I created a class called f68 and, if necessary, use it, I already prescribe the class in the span or div itself: span class="f68" Header /span . Now I found out that the phrase "text-align:center" is often found in my code, but it was possible at the very beginning to create the class "tac" and shorten the code ...
Is there such a code optimizer that, in the case of frequent repetition of one and the same style, create a class with this style and write it to the tag?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
B
bogdan0083, 2016-04-02
@bogdan0083

Using classes like f68 is a bad habit for a lot of reasons. One of them is that the name of the class does not reflect its essence. Instead, you can add classes that define the appearance or state of the element, such as: button-red, button-warning, align-left, and so on.
If you need to reduce the amount of scribbling when laying out, I recommend using preprocessors . This will greatly reduce the amount of code with variables and mixins.
Concerning the optimizer. I don't think there is anything like that.

T
ThunderCat, 2016-04-02
@ThunderCat

The question is not about saving kilobytes, lines or letters, the question is about usability and semantics, read why css appeared at all, because you can put everything into tags. There are no such softins yet, Word, I can be wrong, in our time ... xs what people have written already.
Such things are usually decided by competent developers at the project stage. In your case, search by string with replacement is a normal solution. 4 styles replace - 5 minutes of work.

M
Marina Lebedeva, 2016-04-02
@Margo_shka

Now I've found that I often see the phrase "text-align:center" in my code.

Do you love inline styles? O_O

K
KG, 2016-04-02
@pwnography

and use a variable in the preprocessor in the case of color, no?
And your idea with classes for css properties is complete bullshit!
Forget about it forever and delete the question from here.

A
asd111, 2016-04-03
@asd111

There is one called CSS Optimizer. That that you described is called minimization with change of structure.
https://habrahabr.ru/post/116880/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question