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

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.

主站蜘蛛池模板: 武陟县| 商河县| 疏附县| 上饶县| 游戏| 天台县| 牡丹江市| 洛南县| 永年县| 定边县| 新干县| 鄂托克前旗| 漳平市| 谢通门县| 都兰县| 沁阳市| 霍山县| 自贡市| 洞头县| 沂南县| 聂拉木县| 兴安县| 儋州市| 鄂尔多斯市| 余干县| 东安县| 攀枝花市| 平凉市| 会泽县| 霍林郭勒市| 资溪县| 通州区| 东丽区| 南开区| 安塞县| 海原县| 加查县| 阳原县| 永春县| 莲花县| 宁国市|