Public
Script
October 23, 2023
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
export const htmxTimed = async (request: Request): Promise<Response> => {
const start = performance.now();
const { html } = await import("npm:common-tags");
const afterCommonTags = performance.now() - start;
console.log("after common-tags", afterCommonTags);
const { Hono } = await import("npm:hono");
const afterHono = performance.now() - afterCommonTags;
console.log("after hono", afterHono);
const app = new Hono();
app.get("/", (c) =>
c.html(html`
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">
<script src="https://unpkg.com/htmx.org@1.9.4" integrity="sha384-zUfuhFKKZCbHTY6aRR46gxiqszMk5tcHjsVFxnUo8VMus4kHGVdIYVbOYYNlKmHV" crossorigin="anonymous"></script>
<title>My Val Town Page</title>
</head>
<body>
<main>
<h1>${"My list"}</h1>
<ol id="list">
<button
hx-get="/items/new"
hx-target="#list"
hx-swap="beforeend"
>Add item</button>
<button
hx-get="#"
hx-target="next li"
hx-swap="delete"
>Remove item</button>
</ol>
</main>
</body>
</html>
`));
app.get("/items/new", (c) =>
c.html(html`
<li><p>New item</p></li>
`));
const response = await app.fetch(request);
const afterResponse = performance.now() - afterHono;
console.log("after response", afterResponse);
return response;
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
October 23, 2023