What is server side rendering of javascript?

前端 未结 3 1754
囚心锁ツ
囚心锁ツ 2021-02-02 10:23

Some javascript frameworks like Dust.js claim that they ALSO support server-side rendering (in addition to client side rendering) as well. Can someone explain how does this wor

3条回答
  •  清歌不尽
    2021-02-02 10:37

    JavaScript can be run on servers using systems like Node.js.

    With regard to Dust.js, a templating engine, it can generate hypertext and HTML on the server and send that content directly to the client's browser. This is typically used to avoid a flash of temporarily empty templates, caused by the browser requiring a split second to populate a view's templates via a framework like Dust.js. The downside is that the page will take slightly longer to load because more work has to be done on the server before sending data to the client.

    Check out this question for the pros and cons of server-side rending. One must choose between slow post-processing (requiring the user's browser to do the work) or slow pre-processing (making the server do the work before the user sees anything).

提交回复
热议问题