ManualDev
ManualDev

Reputation: 13

Express + Jade rendering - client or server side?

I just started using ExpressJS and Jade and I was sure that everything is server-side but this post makes me a little bit confused(because my site behaves like Client-side scenario): https://stackoverflow.com/a/12291675

I guess that node.js only sends whole site once and then sends JSON data, because the rest is loaded in browser cache?

So it would be helpful if someone describe this mechanism to me.

Upvotes: 1

Views: 1588

Answers (1)

Peter Lyons
Peter Lyons

Reputation: 146174

You can code an express.js app to render jade templates into HTML on the server side and send HTML to the browser. This is the more traditional approach. However, jade is also capable of running in the browser, so your express app can send jade templates (either as jade syntax text or pre-compiled javascript function source code) to the browser and also send JSON data to the browser and let the browser render the jade template plus JSON data into HTML to be inserted into the DOM. Both are possible. Neither are prescribed by express or jade. It's your choice.

Upvotes: 5

Related Questions