php-autoprefixer
php-autoprefixer copied to clipboard
Some more optimization
I see that you remove zero (0) when it's in expression 0.5px or calc(-0.5em + 10%) etc. which is great and I really love it as it makes final CSS smaller.
What about another optimization? Remove unnecessary quotes? Currently I use this to remove them:
$prefixed_css = str_replace(
array(
'[role="button"]',
'[type="button"]',
'[type="reset"]',
'[type="submit"]',
'[type="search"]',
'[type="file"]',
'[type="checkbox"]',
'[type="radio"]',
'="top"',
'="right"',
'="bottom"',
'="left"',
),
array(
'[role=button]',
'[type=button]',
'[type=reset]',
'[type=submit]',
'[type=search]',
'[type=file]',
'[type=checkbox]',
'[type=radio]',
'=top',
'=right',
'=bottom',
'=left',
),
$prefixed_css
);
I am not sure that is css attribute selector without quote can support all browser, so i can not change it
No one is using without quote https://www.w3schools.com/css/css_attribute_selectors.asp
You can be sure ;) it works if it's just 1 string matching regex [a-zA-Z0-9_]+
You can read about it here: https://www.w3.org/TR/CSS21/grammar.html#grammar
w3schools just shows you best practices when you're learning CSS... yes it's good idea to use quotes when you are a beginner
but when you want to compile most optimized CSS and get best results, then it's a good idea to get rid of all unnecessary characters in it... this means leading zeros in decimal numbers - like you already did, but also unnecessary quotes...
but sure, it's up to you ;) I'm just offering you a better results when we're talking about final file size
PHP-CSS-Parser is behind this autoprefixer, so this can only be fix by that library. ask them if they can help on this https://github.com/sabberworm/PHP-CSS-Parser