Reputation: 599
This maybe a silly question, leading out of my lack of knowledge on this topic. So, please pardon me if it is indeed silly.
I am using a standard MEAN (Mongo, Express, Angular, Node) stack to develop a web application. In the Express configuration I am setting the template engine like so:
app.set('view engine', 'jade');
Now, the way this works is that Express takes care of rendering the jade as HTML in the browser. All nice and neat.
But, I see that many developers use a grunt module called grunt-contrib-jade to convert jade files to html. Is there any benefit of doing this in the previously mentioned setup where I leave it to express to do the pre-processing? Are there any advantages of one approach versus the other?
Upvotes: 0
Views: 356
Reputation: 16612
when you render jade files on each request it's slower than serving a static HTML file.
But you can also cache jade files with express: http://expressjs.com/4x/api.html#app-settings
view cache Enables view template compilation caching, enabled in production by default
There is another solution: compile jade files to JavaScript, serve them as static files and execute / render it on the client.
When compiling Jade to HTML, usually you cannot handle placeholders in the template, but I don't know how grunt-contrib-jade works.
Upvotes: 1