You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Internally, htpy is built with generators. Most of the time, you would render
4
-
the full page with `str()`, but htpy can also incrementally generate pages which
5
-
can then be streamed to the browser. If your page uses a database or other
6
-
services to retrieve data, you can sending the first part of the page to the
7
-
client while the page is being generated.
4
+
the full page with `str()`, but htpy can also incrementally generate pages
5
+
synchronously or asynchronous which can then be streamed to the browser. If your
6
+
page uses a database or other services to retrieve data, you can send the
7
+
beginning of the page while the rest is being generated. This can improve the
8
+
user experience of your site: Typically the `<head>` tag with CSS and JavaScript
9
+
files are sent first. The browser will start evaluating scripts and parse CSS
10
+
while the page loads. Once the actual data, typically part of the `<body>` or
11
+
`<main>` arrives, it can directly be rendered. Typical template based systems
12
+
render the entire page at once and then send it to the client, when the server
13
+
rendered the full page.
8
14
9
15
!!! note
10
16
@@ -14,43 +20,40 @@ client while the page is being generated.
14
20
streaming will be the easiest way to get going. Streaming can give you
15
21
improved user experience from faster pages/rendering.
16
22
17
-
This video shows what it looks like in the browser to generate a HTML table with [Django StreamingHttpResponse](https://docs.djangoproject.com/en/5.0/ref/request-response/#django.http.StreamingHttpResponse) ([source code](https://github.com/pelme/htpy/blob/main/examples/djangoproject/stream/views.py)):
0 commit comments