CSS Expressions

I’ve come across expressions in CSS style sheets and decided to investigate if they really were as powerful as they seem. Expressions are JavaScript code that is applied as part of a class in the style sheet,  this is useful for keeping all the elements of that class from expanding beyond a specific size for instance . While it may seem like a good idea it turns out that it is more likely to cause your webpage to lag. Expressions are re-evaluated every time there is any interaction with the page, instead of when you want it too.

The best practice is to use JavaScript. Especially with JavaScript libraries and frameworks out there the need for css expressions are gone. My recommendation is to Avoid CSS Expressions, use JQuery, Prototype, MooTools or Scriptaculous instead

Posted by Jason McAlpin

Jason Mcalpin is a full stack developer and game designer. Jason has been programming for over 30 years from the days of punch cards and COBOL. Things have progressed since then and continue to move at a furious pace and Jason explores all of the latest trends in the field.