weixin_33716941 2013-06-20 14:14 采纳率: 0%
浏览 34

没有模板的Expressjs

I am looking to develop an web application which is basically one page and I am little confused regarding two things.

  • Now I am little confused as to what should my response from server-side(i.e node.js) be? I wanted to mostly response with json and then render them in client-side using javascript templates but one more option is to to render templates from server-side itself and just let the client javascript just load it and put into place.

What are the advantages and dis-advantages of each of the methods?(speed is a criteria I would value a lot).

  • And should I send json from browser using ajax to the server or built forms and send forms?. I am leaning towards json but still wanted to know which one would be better.

You can be descriptive in your answer.

Help me. Thanks.

  • 写回答

1条回答 默认 最新

  • YaoRaoLov 2013-06-20 15:14
    关注

    I think the debate is the same for Node.js than for any other tech.

    With a classic MVC solution and server side template, all the computation is made server side and pure HTML is sent to the client. The response could take longer but the browser, and the client computer, are not heavily used. It's easiest to maintain if you are not confident in client side Javascript. I think it would be easiest as well for caching.

    On the other side, the match up solution, made generally by calling API with Ajax, put more heavy computation on the client browser and leave your server globally alone. You can even think about a full static page for example that populate his content only with JavaScript. You have to be more confident with JavaScript (And use stuff like Angular.js for example). The response will be faster but the user experience will be different from a client point of you. So you will have to put more efforts on the design.

    This second solution let you choose another technology for the API. And you will find lots of help for both.

    But I would say that neither of those solution are radically faster than the other (Depending of what you do), but it's a matter of the user you have (JavaScript might be better handled in a recent browser) and you confidence in JavaScript.

    Though, these days, for a one page website, the trend seems to be in favour of the couple API + Ajax call.

    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记