Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How much does include statements hinder performance?

I am currently writing a node server, using express and ejs for the tempting engine. Some of my .ejs files have 7 - 8 include statements for partials nested inside of them. I was wondering if this is resource intensive, or if it will be fine.

like image 621
Programmer Avatar asked Mar 27 '26 07:03

Programmer


1 Answers

EJS maintainer here.

First off, if you're reading the same file many times in a row, the filesystem will cache it on that level.

However, if you want maximum performance, set cache: true in the options. (docs) You must be using renderFile() or passing in the filename to get this to work. If you're using Express, cache: true is set automatically when NODE_ENV is set to production.

Keep in mind that this assumes that your files never change. i.e. if you change a file, EJS will just use the old cached version until you restart the server process.

like image 114
RyanZim Avatar answered Mar 28 '26 23:03

RyanZim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!