CSS calc functions are collapsed and so non-functional




Wordpress LScache Plugin: CSS calc functions are collapsed and so non-functional

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi, Im not sure which part of the minification is at issue but somewhere in the Litespeed / QUIC pipeline theres a minification which is colapsing spaces in CSS calc . Calc wont work without spaces so This is valid .element margin-bottom: calc(-1 var(--grid-row-gap)) This is not valid and will not render the margin value .element margin-bottom: calc(-1 var(--grid-row-gap)) currently my logged in users (no cache / minify) are seeing correct css calcs, and visitors (cached) are seeing the minified erroneous calc. I tested the issue by visiting admin.php?page=litespeed-toolbox debug page and disable all features . And that shows all calc values return to correct display values. Reactivating Litespeed brings back the issue. Ive tried a disabling a few relevant toggles in the /page optimisation but so far Ive not found the culprit and need to set up a dedicated test site to find the specific cause. Suggested test HTML some content CSS div height:500px width:calc(100vw - 200px) background:red That should display a red rectangle with width narrower than the body. Now Activate Litespeed CSS compression. That will very likely display the red rectangle 100% of the width of the viewport. ENVIRONMENT NOTES PHP7.4, WP 5.8.1 Litespeed Version 4.4.2 Further investigation, Ive found the error in your plugin Lines 547 and 550 of https://github.com/litespeedtech/lscache_wp/blob/master/lib/css-min/minifier.cls.php // Remove spaces before the things that should not have spaces before them. $body = preg_replace(/ ([:=,) / ])/S, $1, $body) // Remove the spaces after the things that should not have spaces after them. $body = preg_replace(/([:=,( /! ]) /S, $1, $body) this will strip spaces around the asterisk character. that character needs spaces around it for calc() raised it on GH https://github.com/litespeedtech/lscache_wp/issues/405



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference