3 ms·
Well maybe I'm blind, but I honestly don't see the benefit of CSS compilation. Client side is the only use case I'd even consider, I've been using php to augme
by r0s 14y ago
Well maybe I'm blind, but I honestly don't see the benefit of CSS compilation. Client side is the only use case I'd even consider, I've been using php to augment styles for years.
Yet, js compiled CSS seems like it breaks tools like Firebug or the Chrome inspector. And version control systems.
What am I missing?
- ericclemmons 14y agoYou've used PHP to augment styles (as have I), I've even used Twig, and have now been using LESS. Version control is no different, and you typically compile on the server before sending to the client. The LESS.js shim is for convenience, like when you're editing a site over FTP with no access to the server. CSS precompilers help DRY up your code and introduce structure. For example, no more repeating that hex value and forgetting which red is the error red vs the logo red, constantly retyping vendor prefixes, or maintaining a single gigantic stylesheet. As a PHP developer, I prefer to "refresh to see changes", which is why using Assetic is a must for compiling both CSS and JS resources.
- youngtaff 14y agoCompiling CSS client-side slows the page load down... For less.js the browser has to download the js, then the less file and then produces the CSS Until the browser has the CSS it can't start rendering the page. Here's a waterfall for lesscss.org (http://www.webpagetest.org/result/120509_18_ff2ca6e34c6b8e9085b97168d3bcc72d/1/details/ http://www.webpagetest.org/result/120509_18_ff2ca6e34c6b8e90...) notice how for a really simple webpage that the rendering doesn't start until over 1.2 seconds in!!!
- SquareWheel 14y agoBy augmenting CSS with PHP, do you mean something like this? p {color: <?=$mainColor?>} And then just setting .htaccess (or whatever) to allow PHP execution in .css files?
- r0s 14y agoYou can just process main.css.php (or whatever) Here's some of my (old crappy)code: color: <?php echo $foreground1; ?>; font-family: <?php echo $font2; ?>; But I'm sure there's libs out there that make it really easy and pretty.