10

Assuming that we have millions of requests per day. Is the HTML processing in Node.js with Jade slower or faster than PHP's render engine? Or doesn't matter because the difference is really small?

I'm using Node.js with the Jade template engine, I really like it. But I was always the guy who worried about performance. I started my developer career with PHP, it was fun but now Node seems much much better, so I decided to switch.

I use Jade to Render HTML, because node.js alone lacks it(I know this sounds a bit stupid because Jade is node too :P). But because Jade is a module in Node I'm a bit confused, maybe this can slow the rendering process down.

Adam Halasz
  • 57,421
  • 66
  • 149
  • 213
  • 1
    You do realize latency & db access are generally the main bottlenecks. I'd be highly tempted to say templating is significantly faster in v8 because v8 is just _fast_ (benchmarks claim 5x-50x faster then PHP) – Raynos Jun 01 '11 at 08:11
  • @Raynos v8 is [useless when you use `with` statement](http://stackoverflow.com/q/20354779/995876) ... :d thank god jade removed it. It was 3x slower than php in techempower benchmarks. Hopefully next time they use updated versions of libraries :-) – Esailija Dec 05 '13 at 06:44

4 Answers4

5

Jade isn't designed for speed, it's designed for elegance. If you're really concerned with speed there are other javascript rendering engines that are faster.

Check out http://jsperf.com/dom-vs-innerhtml-based-templating/63 (note that the chrome results match closely to node.js performance)

But that's all assuming the rendering engine is the bottleneck, and not the DB.

generalhenry
  • 17,227
  • 4
  • 48
  • 63
3

First off, I know this is VERY OLD but I would like to meta tag my benchmark to help other seeking the Jade vs decisions. I added a benchmark comparing both recently since I got stuck picking out a template engine. I choose twig because I already used it and have never used Jade. I do like how simple Jade is and can be beneficial for getting "quick web apps" up however I've written HTML and CSS for over 15 years and seeing the markup makes me smile.

Express - Jade vs Twig Benchmarks:

Community
  • 1
  • 1
Jesse
  • 307
  • 2
  • 5
2

Jade templates are memory cached, so the second request will be almost immediate. If you are concerned about templating speed with jade, you can use self option.

masylum
  • 22,091
  • 3
  • 20
  • 20
0

The views in Jade are compiled to actual Javascript, and then cached for latter use. In terms of rendering Jade is as fast as rendering a page written in raw Javascript. The compile time does add an initial over head, but you should only need to compile the code once(most likely when node initially starts up).

Your welcome to run the tests, but basically php is typically interpreted on each request(obviously memache does kick in), while the jade views should be completed cached in memory.

Lime
  • 13,400
  • 11
  • 56
  • 88