Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a SASS.js? Something like LESS.js?

Tags:

css

sass

less

I have used LESS.js before. It's easy to use, something like

<link rel="stylesheet/less" href="main.less" type="text/css"> <script src="less.js" type="text/javascript"></script> 

I saw SASS.js. How can I use it in a similar way? Parsing a SASS file for use immediately in HTML. It seems like SASS.js is more for use with Node.js?

var sass = require('sass') sass.render('... string of sass ...') // => '... string of css ...'  sass.collect('... string of sass ...') // => { selectors: [...], variables: { ... }, mixins: { ... }} 
like image 279
Jiew Meng Avatar asked Dec 14 '10 06:12

Jiew Meng


People also ask

Does Sass require JavaScript?

Sass is a pre-processing language, meaning it's turned into CSS before it ever is a part of a website. For that reason, accessing them from JavaScript in the same way as CSS custom properties — which are accessible in the DOM as computed styles — is not possible. We need to modify our build process to change this.

Why is Sass so slow?

Sass becomes slowly as many SASS files are included to the process. Big SASS-Frameworks tend to use a lot of files and latest when you use a lot of big modules it heavily could slow down at all. Sometimes there are more modules included than needed.

Can you use sass without NPM?

Yes, we can compile SCSS/SASS to CSS without using any Node Command.

Is CSS better than sass?

SCSS contains all the features of CSS and contains more features that are not present in CSS which makes it a good choice for developers to use it. SCSS is full of advanced features. SCSS offers variables, you can shorten your code by using variables. It is a great advantage over conventional CSS.


1 Answers

There is no officially sanctioned JavaScript implementation of sass or scss. There are a couple of implementations in progress that I've seen, but none that I can recommend using at this time.

However, please a few points:

  1. Why should you make all your users compile your stylesheets when you can do it once for all of them.
  2. What would your site look like if JavaScript is disabled.
  3. If you decide to change to a server-side implementation at a future time, all your templates must be changed accordingly.

So while it's a little more setup to get started, we (the sass core team) think that server side compilation is the best long term approach. Similarly, the less developers prefer server side compilation for production stylesheets.

like image 131
chriseppstein Avatar answered Sep 28 '22 01:09

chriseppstein