Reputation: 887
So I'm trying to create a website that almost runs only on the clientside using symfony2, backbonejs and underscore. symfony2 for the backend and backbonejs for the frontend. Symfony2 uses twig templates which get compilled into php classes by the server.
Would it save server performance to avoid twig templates as often as possible and use javascript templates (underscore) instead? Or doesn't it make a difference since the templates need to be fetched from the server anyway?
Upvotes: 0
Views: 71
Reputation: 943614
Fetching a static file from the server is always going to give you better server performance than having the server process a template and return the result. The chances of that being significant are pretty low though, and you'd have to benchmark it to find out how much difference it makes.
Fetching a static template file from a server and fetching a dynamically generated data file to inject into it may or may not give you better performance then having the server insert the data into the template. You'd have to benchmark it.
Performance benefits of using client side templates almost always come from:
The benefits do have to be weighed against the costs though (which are either the additional work to make the site continue to work if JS isn't available combined with the use of pushState
and friends to have workable URLs or the fragility and search engine invisibility of a site completely dependant of JS)
Upvotes: 1