This is a static dump of issues in the old "Flyspray" bugtracker for DokuWiki. Bugs and feature requests
are now tracked at the issue tracker at Github.
Closed
Implemented
FS#2509 Css little more compaction
Backend
2012-05-03furun
little more compaction
compact "margin: 1px 1px 1px 1px" to "margin: 1px"
I don't see the point of this. Writing "margin: 1px" is best practice anyway and should be used all across the core at least.
Furthermore I feel uneasy when it comes to rewriting actual code. So far, we let css.php only rewrite white space and replace patterns.
2012-05-27furun
yes, the compression is little
it compress
margin: 1px 1px 1px 1px;
margin: 1px 2px 1px 2px;
to
margin: 1px;
margin: 1px 2px;
the compression is small, like #FFFFFF to #FFF
(don't get me wrong, i don't fight for implementation, just share some maybe useless perfectionism :)
2013-09-24Klap-in
This additional compression costs more computation time and reduces barely the file size, isn't?
2013-09-24andi
Doesn't the less compiler do that kind of optimization now anyway? Can someone check?
2013-09-24Klap-in
So fast i don't read anything about this kind of optimizations.
Also i tried to add 'padding: 3px 3px 3px 3px;' to the demo at http://leafo.net/lessphp/, but it is not optimized to 'padding: 3px;'
Next i tried it in DokuWiki too, but it is not optimized too.
2013-10-12andi
Well, we do this kind of optimization for colors already (#ffffff to #fff) so I'm not completely against it. But I'd like to have unit tests for this. furun, I'll close this for now, but if you send a pull request with the change and accompanying unit tests I'll apply it.
2013-10-13furun
sorry for the pause...
i compare the dw css files and check them manually for errors.
the regexp is more robust then that used for #ffffff compression, because it dont change names like div#fffffff { ...;}
(switch of caching before testing. speed is irrelevant because the result is cached. and like i set is is more perfectionism and not extremely important :)
this is a update for Patch_2012-04-27-CssPlus.zip
--------------------
// number compression
$css = preg_replace('/([: ])0+(\.\d+?)0*((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/','$1$2$3',$css); // "0.1em" to ".1em", "1.10em" to "1.1em"
$css = preg_replace('/([: ])\.(0)+((?:pt|pc|in|mm|cm|em|ex|px)\b|%)(?=[^\{]*[;\}])/','$1$2',$css); // ".0em" to "0"
$css = preg_replace('/([: ]0)0*(\.0*)?((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/','$1',$css); // "0.0em" to "0"
$css = preg_replace('/([: ]\d+)(\.0*)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/','$1$3',$css); // "1.0em" to "1em"
$css = preg_replace('/([: ])0+(\d+|\d*\.\d+)((?:pt|pc|in|mm|cm|em|ex|px)(?=[^\{]*[;\}])\b|%)/','$1$2$3',$css); // "001em" to "1em"
((As a tip. Compression functions could be placed in common.php in case a plugin can use it. i used a min plugin with a text box for more testing))
((i am a hobby coder, pleas forgive me if i dont use Github but post all patches here.))