Bitpath

Lesson 1 · Unit 04

Where the HTML is made

Static, server and client rendering, hydration, the edge

13 exercisesabout 3 min

What you practise

  • Server, client and static rendering, hydration and its cost, streaming, running at the edge

Try a question from this lesson

Pick one

This is all the HTML of a news article page, and app.js is 500 KB. What does a reader on a slow phone see while app.js downloads and runs?

HTML
<body>
  <div id="root"></div>
  <script src="app.js"></script>
</body>

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Three places to make HTML

Static: pages are built once, before anyone asks, and the same file is served to everyone. It can sit in a cache near every user.

Server: HTML is built for each request. It can be fresh and personal, but the server's work comes before the first byte.

Client: the server sends a nearly empty page and JavaScript builds the content in the browser. Nothing shows until that script has run.

static   built once, at deploy time
server   built per request
client   built in the browser, by JS

Concept

Hydration

Server-rendered HTML is a picture of the app. The button is there, its click handler is not: handlers are JavaScript, and the JavaScript has not run yet.

Hydration is the browser running the app's code to attach handlers and state to markup that already exists.

Until it ends, the page looks ready and is not. And hydration is itself a long task on the main thread.

0.5 s  HTML painted: looks ready
       taps find no handlers
2.0 s  app.js has run: handlers attached
       now it really is ready

10 more exercises in the app

  • 1× match the pairs
  • 2× type the answer
  • 4× multiple choice
  • 2× true or false
  • 1× order the lines

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy