What is server side rendering of javascript?

心不动则不痛 提交于 2019-12-18 01:44:09

问题


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 work? My understanding is that the JS is always executed in the browser runtime.


回答1:


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).




回答2:


Server side rendering is converting JavaScript into static html and css. Earlier JS tended to load last to optimise website performance. But the problem was it affected SEO. So server side rendering became the solution to resolve this issue.



来源:https://stackoverflow.com/questions/16173469/what-is-server-side-rendering-of-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!