开发者

Does using Haml and Sass slow things down?

开发者 https://www.devze.com 2023-01-28 13:26 出处:网络
When you use开发者_开发知识库 Haml and Sass, does it slow things down all the time or just for the first time the view is rendered?

When you use开发者_开发知识库 Haml and Sass, does it slow things down all the time or just for the first time the view is rendered?

I'm sure it isn't a big performance penalty, but just curious as to how things are rendered.


As Michael and jxpx777 said, Sass gives you only a one-time slowdown. Haml, according to this benchmark, is as fast as Erb (assuming Haml 3 hasn't gotten slower than Haml 2.2). So the answer is, no it doesn't slow things down all the time.

Haml (like Erb, I will assume) has a precompiler, so it does some work up-front and then spits out the rendered views pretty fast.


Not sure about haml. Sass will spit out a .css file when rails starts up so once it's created it has zero effect on speed as the web pages reference the outputted .css file.


HAML shouldn't have too much performance difference to ERB. It's the same kind of process. SASS will experience a performance hit the first time it has to generate the CSS files, but I do that as part of my Capistrano deployment script so that no users have to see that performance hit.


If you use this while writing your SASS, you'll not have any slowdown whatsoever, as it generates (and syntax checks) your SASS as you write it:

sass --watch screen.sass:screen.css

HAML is not slower than ERB.

0

精彩评论

暂无评论...
验证码 换一张
取 消