3

I am working on a webapp using nodejs. I was originally going to just server side hbs template, but then I found out about backbone for client side templating. I found out it can fetch data from server then display it using hbs template, instead of server side generate entire html page and send. But then I also read somewhere people suggest that it is not good practice to have many ajax calls in client side to get data and display for one webpage, it would have so many request to server, and the page would appear to be slow. so I am wondering is there general rule how many requests can be made for one page? Should I use classic one request one respond? or should the respond be some client side javascript which then fetch data from server and display them ?

Thanks

4

1 回答 1

1

我发现最好的解决方案是在服务器端呈现模板,然后让 Backbone 应用程序将自身附加到服务器呈现的元素。我使用 Jade 作为我的模板引擎,它允许我在服务器端和客户端重用模板。你应该花一些时间阅读这个链接。如果您确定这是您要查找的内容,请在此处安装该应用程序。

我发现上述解决方案最不自以为是。您还可以非常快速地阅读代码并了解项目背后的想法。它只是将一堆不同的技术结合在一起,有助于在客户端和服务器代码可重用性方面发挥最佳作用。在服务器端进行渲染时,即使感知性能也非常出色。您还可以获得渐进增强的额外好处,并解决您在使用 SEO 和单页应用程序时遇到的任何问题。

于 2014-07-28T11:48:08.490 回答