skip to content rich footer

stevenclark.com.au

subscibe to the StevenClark.com.au rss feed

Archive for the 'css' Category

CSS Preprocessing with JavaScript is a Bad Idea

Monday, June 21st, 2010

Dmitry Fadeyev posted an article titled Less.js Will Obsolete CSS a few days ago and I thought it worth mentioning in a post here. My short response is that I disagree with the idea of using JavaScript to pre-process Cascading Stylesheets (CSS).

As a web standardista, my first and foremost response is that best practice web standards methodology is to separate content (HTML) from presentation (CSS) from behaviour (JavaScript) in web design. Moving presentation (CSS) to the behaviour layer (JavaScript), which is the fundamental idea underlying Less.js, is therefore something that I would never recommend regardless of any accrued performance benefits.

The benefits accrued through separation of these three layers far outweigh any performance response available by downloading yet another JavaScript file.

Best practice web standards methodology also puts forward the concepts of progressive enhancement and graceful degradation. This means you either start with the idea of building a basic user experience and enhancing it for those who have better browsers… or you build better users experiences that degrade well for users who have lesser browsers.

The benefits accrued from those two concepts are vital to providing high quality professional experiences to end users of any website. I would call them a baseline. Yes you can do great and wonderful things as long as the intelligence is in-built to adapt to the unexpected – because the crux of the World Wide Web is that we have zero control over user’s hardware / software / settings.

Even if the argument that only 5 per cent (or 1 per cent) of web browsers had JavaScript disabled that would equate to many millions of people on the World Wide Web. Add to that percentage the still huge numbers of lower end mobile devices, particularly when you look at developing economies. So I’m far from sold on the idea that everybody has JavaScript enabled.

For example, 10-25 per cent of screenreaders are JavaScript disabled. [This statistic simply serves as an example that we can never strategically take 'JavaScript enabled' for granted in our work.]

I’ve probably got other more technical questions… but I needn’t go further within my rationale. This is a smart solution using the wrong tools based on unsound assumptions about user capabilities. I have enormous respect for Dmitry and his capabilities but on this one I have to disagree. Less.js isn’t a CSS obsoleter by a long margin.

The reason I am writing this article and stating my opinion (comments off) is that I think its an unhealthy mindset for other developers to emulate. We’ll just have to agree to disagree, I guess.

Update: 21 June, 2010
If I asked you this question then – would you build a JavaScript main navigation on a website assuming that everybody has JavaScript capabilities? Or a JavaScript shopping cart on your ecommerce website? I think we’re having the 2003 DHTML conversation again.

Social Networking

Keep an eye out for me on Twitter

About the Author

Steven Clark Steven Clark - the stand up guy on this site

My name is Steven Clark (aka nortypig) and my passions are business, web development, photography and writing. My current CV [PDF 619KB] is available for download. I have an MBA (Journalism and Media Studies) and a Bachelor of Computing from the University of Tasmania.

Photography

My photography is at Steven Clark Studio and my regular photo blog presents an ongoing stream of latest images at Walk a Mile in my Shoes and I'm working on a long-term photography project called the King Island Project.

Recently Reviewed Books

Site Supporters

Hosted by Brett Drinkwater at Tashosting who is always there at the other end of my every inconvenient question and technical crisis. Brett's local community support for us over the last five years is greatly appreciated.

skip to top of page

Currently Reading

Ansel Adams: The Camera

As the first of three parts of Ansel Adams Photography Series, Ansel Adams: The Camera begins by discussing the idea of visualisation in relation to photography. Ansel Adams is a master of his craft; this series has sat on my backburner for some time. Book 2 in this series is The Negative and it's followed up by The Print. In them Ansel outlines his philosophy of photography rather than trying to lay down a set of rules. This first instalment is a technical book that explains the good old fashion film camera.