Daily Archives: January 15, 2012

Experimenting with LESS

I’ve been exploring LESS this weekend as a way to make writing CSS a much more efficient affair. So far, so very good! I’m using LESS.app for Mac OS X to compile my .less files down to CSS with each save. There are Ruby scripts and JavaScript available for interpreting LESS on the fly, but I far prefer to serve up already-baked CSS with the app, which gets bonus points for spitting out minified files. Be careful with the minifier, though, if you’re writing CSS with LESS for WordPress (try saying that three times fast) — it will strip the comment block WordPress needs to identify your theme from the CSS file. There are a couple workarounds for this; the easiest way is probably just to use a minifying WordPress plugin (I use W3 Total Cache’s minifying facility myself), or if you want your server to have one less thing to do, you can spit the minified files out to a different location, reference that location in your HTML, and just use style.css as a way to identify the theme and for nothing else. (WordPress doesn’t require you to store your styles there, but it is generally more consistent to do so.)

Using the app has another great side benefit as its compiler flags errors it finds in the code and tosses up a Growl notification with a brief explanation of the problem — so not only am I writing CSS more efficiently, I’m also writing much more error-free CSS as a result. Win-win.

Who else is using LESS (or its contemporary SASS) to write and simplify CSS?