wyc
wyc

Reputation: 55273

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

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?

Upvotes: 6

Views: 2575

Answers (4)

kurroman
kurroman

Reputation: 976

Other options is making your own less compiler in server and then you can "play" with cache times css results.

You can check libraries as LessPHP in order to do that.

Upvotes: 0

Daniel
Daniel

Reputation: 1062

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:

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

Upvotes: 8

Colin
Colin

Reputation: 287

It really depends on what you're building and who your target audience is. Modern browsers that support HTML5 will cache the generated CSS the first time it loads so if the majority of your visitors will be using modern browsers it's pretty safe.

Upvotes: 0

Plynx
Plynx

Reputation: 11461

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.

Upvotes: 3

Related Questions