Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Would it be a bad practice to use less.js in a production site (client-side javascript compliler for LESS style-sheets)?

Tags:

less

This script basically turns .less code into .css code. I think it will only cause problems if the user has javascript turned off, but do many people do that?

Any suggestions?

like image 954
alexchenco Avatar asked Mar 30 '11 06:03

alexchenco


People also ask

What is Less js?

Overview. Less (which stands for Leaner Style Sheets) is a backwards-compatible language extension for CSS. This is the official documentation for Less, the language and Less.js, the JavaScript tool that converts your Less styles to CSS styles.

How can I download less js?

You can download the latest version of less. js from http://lesscss.org/ and copy this file into your working directory.


2 Answers

Just compile the .less into .css before putting it into a production environment. That way it will still display to those without JS enabled, and won't suffer the issues @Plynx mentioned.

As for compiling, there are some real-time compilers out there, specifically:

  • For Mac - less.app
  • For Windows - Less Parser

Both compile .less to .css on file save, which is awesome, and makes LESS easier to use!

like image 120
Daniel Avatar answered Dec 31 '22 20:12

Daniel


Many people do (I don't have exact numbers, but IIRC less than 4%), but you are under no obligation to provide functionality without javascript. Many of the more advanced sites today do not. It depends on what you are serving and who your audience is.

Of course it's great to provide this functionality if you can. I would be more concerned about the effect less.js will have on your site's load time. If you can't load the CSS until after the javascript, you have to delay rendering until the javascript runs, in order to avoid an unseemly transition from unstyled to styled.

You can have your .less files auto-compile into CSS whenever they are changed by using tools that watch directories.

like image 42
Plynx Avatar answered Dec 31 '22 19:12

Plynx