官术网_书友最值得收藏!

Server-side rendering

Server-side rendering is a great way to increase the perception of loading speed in full-stack apps. Users get a complete page with visible content when they load your site, as opposed to an empty page that doesn't get populated until JavaScript runs.

Say we have an app built with components. If we use our browser development tool to view our page DOMafterthe page has loaded, we will see our fully rendered app:

<p id="app">
  <ul>
    <li>Component 1</li>
    <li>Component 2</li>
    <li>
      <p>Component 3</p>
    </li>
  </ul>
</p>

But if we view the source of the document, that is, index.html,as it was when sent by the server, you'll see it just has our mount element:

<p id="app"></p>

Why? Because JavaScript is responsible for building our page and, ipso facto, JavaScript has to run before the page is built. But with server-side rendering, our index file includes the HTML needed for the browser to build a DOM before JavaScript is downloaded and run. The app does not load any faster, but content is shown sooner.

主站蜘蛛池模板: 泾川县| 句容市| 子长县| 武冈市| 安康市| 故城县| 桦甸市| 仙游县| 莒南县| 武城县| 清流县| 辽宁省| 宁夏| 漳州市| 永川市| 西吉县| 兰州市| 日土县| 舞阳县| 沁水县| 壤塘县| 大余县| 富蕴县| 明光市| 习水县| 泗阳县| 大悟县| 宽甸| 四会市| 旬阳县| 唐河县| 开阳县| 库车县| 武强县| 绥滨县| 巴东县| 揭西县| 金川县| 札达县| 安康市| 盐津县|