6 ms·
I am sorry, maybe I am missing something important, but what is a logical difference between what you propose and concepts like ASP, PHP, ASP.NET? I am using te
by zbychuk 14y ago
I am sorry, maybe I am missing something important, but what is a logical difference between what you propose and concepts like ASP, PHP, ASP.NET?
I am using templates in all pages, but only because data is known only on a client, i.e. I get data from AJAX call and fill-in a template (jsrender, knockout, others)
- charliesome 14y agoPeople have this belief that server side templates are slow.
- kevincennis 14y agoFor certain applications, they are. If I have a single page web app, I don't want the overhead of returning markup. I just want JSON. And when I get raw data back instead of a string of HTML, I can be a lot smarter about responding to user input (e.g. optimistic updates).
- ahoge 14y agoWell, you send something to the server, then the templating happens, and then it's sent back to you. Even indefinitely fast templating would be slow due to network latency. Also, sending JSON back and forth is kinda nice because it's fairly compact, easy to handle on both sides, and additionally this particular API may be used for other purposes, too.
- drivebyacct2 14y agoIs this said in good faith? There are lots of reasons for client side templates, but I rarely (never) see anyone citing it because rendering on the server is slower than rendering on the client.
- sirclueless 14y agoClient-side rendering probably isn't faster than server-side rendering in terms of latency, but it is cheaper. You save on server processing and network bandwidth. Rendering speed isn't the reason server-side templates feel "slow" though: if you do server-side rendering then every change of state on the client needs to round-trip to the server in order to fetch a new HTML representation. Client-side rendering lets you "cheat": just render the new state and synchronize with the server after the fact.
- drivebyacct2 14y agoRight.
- aymeric 14y agoHow would you make asp.net rendering work with Knockout.js?
- zbychuk 14y agoThis article is about rendering HTML using template engine on the server. I believe this can be (and probably should) be done using existing server side engines, while javascript templates are to be used on the client. Of course if someone is using node.js as a server, then my arguments are not valid, but choice of server is another huge subject to discuss.