Page MenuHomePhabricator

CSSMin::minify could trim more spaces
Closed, DeclinedPublic

Description

Based on the source[1] it currently trims:

  • '; ' => ';'
  • ': ' => ':'
  • ' {' => '{'
  • '{ ' => '{'
  • ', ' => ','
  • '} ' => '}'
  • ';}' => '}'

That still leaves room for improvement of 3 cases (found out through bug 35492).

  • Space before }
> return CSSMin::minify("foo { prop: foo }");
foo{prop:foo }
  • Space before :
> return CSSMin::minify("foo { prop : foo; }");
foo{prop :foo}
  • Space before ;
> return CSSMin::minify("foo { prop: foo ; }");
foo{prop:foo }
  • Space before ,
> return CSSMin::minify("foo { prop: foo , bar ; }");
foo{prop:foo ,bar }

Especially the latter two (space before comma or semi-colon) are a fairly common programming style by the "space-extremists".

foo {
    prop:
      voo( .. ) ,
      voo( .. ) ;
    prop: foo ;
}

I'm not going to be bold on this one because I haven't checked whether there are any side-effects to these 4 changes, but they seem easy gains :)

[1] https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/libs/CSSMin.php?revision=110557&view=markup#l210


Version: 1.17.x
Severity: enhancement

Details

Reference
bz35493

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 22 2014, 12:16 AM
bzimport set Reference to bz35493.
bzimport added a subscriber: Unknown Object (MLST).
Krinkle renamed this task from CSSMin::minify could trim a little more to CSSMin::minify could trim more spaces.Sep 20 2017, 7:14 PM
Krinkle updated the task description. (Show Details)
Krinkle removed a subscriber: wikibugs-l-list.

Closing this as it's truly a point of diminishing returns. Also, it shouldn't happen without doing T37492 first to increasing risk of corruption.