This space is up to! important` is important in some cases, and if so, when? And why?

I experimented with the scssphpPHP SCSS compiler and, in particular, its compressed formatting.

This outputs something like (note the extra spaces and semicolon before the closed curly brace)

.navbar{margin-bottom  :0px !important;margin-top    :4px;}

and so I thought about implementing this small modification to shave a few bits from the resulting code.

I know that this makes little sense, because I will save no more than a few percent; and I delete information with low entropy, which means that as soon as I kill it, the savings will be even less; whereas the modification must be saved. But it seemed simple enough and harmless enough, and I ... kind of did it for Lulz.

4225    public function format($block) {
4226        ob_start();
4227        this->block($block);
4228        $out = ob_get_clean();
4229---     return $out;                        // OLD
4229+++     return $this->postprocess($out);    // NEW
4230    }

, :

4232    protected function postprocess($text) {
4233        return $text;
4234    }

... while in scss_formatter_compressed :

+++ from line 4343:

protected function postprocess($text) {
    $xlat = array(
        '#\\s+(:\\d)#'          => '\\1',
        '#;}#'                  => '}',
        '#\\s+(!important)#'    => '\\1', 
    );
    return preg_replace(
        array_keys($xlat),
        array_values($xlat),
        $text);
} 

:

.navbar{margin-bottom:0px!important;margin-top:2px}

... SCSS . SCSS, .

, !important. YUI-, , ,

@tml @namanyayg , "" ?

https://github.com/GoalSmashers/clean-css, , , .

, , . - .

, OP , , , !important.

, CSS-, scssphp; SCSS, , , , SCSS . , , .

+4

All Articles