Group code in a row

Asked

Viewed 107 times

6

Well, I would like to change my CSS code by joining the parameters that are "joinable"

For example this code:

{
    margin-top: -2px; -> juntável com MARGIN
    margin-right: 40px; -> juntável com MARGIN
}

the parameters margin-X, padding-X among others are joinable in this formula:

parameter: (TOP, RIGHT, BOTTOM, LEFT);

in case it would look like this:

{
    margin: -2px, 30px, 0, 0;
}

How to do it in PHP or Javascript this script that would make this process?

  • 4

    Two things: 1) compressing and optimizing is good, but if your server uses gzip, often the gain is null, since after compressing often the stream ends up being almost the same size. 2) You explained your thinking well, and your intention well. But the site has the focus of questions and answers. What would be the question in this case? The suggestion would be that you go on developing and asking specific questions as you have difficulties.]

  • @Bacco I believe that even for those who will touch the code in the future, it is better to catch it in a clean way, I find these margin-X dirt.. The question would be how to do this in PHP, I have no idea..

  • 1

    really would be very broad this way. Not that it is not a relevant doubt, but it is a fairly complex task, with many logical steps. Start by reading the CSS, then parse this CSS, then implement the logic to regroup the data from this parse, and so on. It would be either the case of looking for something ready (should have some good alternatives in this sense) or go really developing each of the steps, and asking separately each of them as soon as you mastered the previous step.

  • 3

    Read Best practices to improve site performance (in English) to learn what really can make a difference and some things not so significant

  • In primeiro pega o código dentro de {}, you would have to check the existence of media-queries etc that also use keys.

  • this is the problem I don’t know how to do, I’m not familiar with PHP

  • 1

    http://answall.com/questions/101208/sass-vs-less-vs-stylus-diff%C3%A7as-structural-and-syntax

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.