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

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.

主站蜘蛛池模板: 石柱| 金阳县| 阿拉善左旗| 石台县| 夏津县| 宜黄县| 东宁县| 铜梁县| 铅山县| 宜兰市| 张家界市| 容城县| 大悟县| 温宿县| 赞皇县| 海阳市| 天镇县| 长岛县| 无棣县| 吴忠市| 庄河市| 集安市| 疏附县| 台安县| 马边| 尚义县| 叙永县| 桃园县| 龙岩市| 邹城市| 鄢陵县| 美姑县| 平江县| 梅州市| 宣城市| 新闻| 秀山| 平凉市| 永年县| 屏东市| 灵山县|