18 |
19 |
20 | Next-Gen
Serverside
JavaScript!
21 |
22 |
23 |
24 |
25 | Hi, I'm
Wes Bos
26 |
27 | Hamilton, On 🇨🇦
28 | @wesbos on 𝕏, gram, tok, tube and suits
29 |
30 |
31 |
32 |
33 |
Web
Dev
Courses
34 |
35 |
+
36 |
37 |

40 |
syntax.fm × @syntaxfm × sentry
41 |
42 |
43 |
44 |
45 |
46 | What is this talk about?
47 | Server Side JavaScript
48 |
49 |
50 |
51 |
52 | JavaScript Runtimes
53 | Engines + APIS === Runtime
54 |
55 |
56 |
57 |
68 |
69 | V8 → 

72 |
73 | Spider Monkey → 
74 | JavaScriptCore → 
75 |
76 |
77 |
78 |
79 |
80 |

81 |
Node.js
82 |
83 |
→
84 |

85 |
86 |
87 |
88 |
89 |
90 |
91 |

92 |
Deno
93 |
[Deno Deploy, Netlify Edge, Supabase Edge]
94 |
95 |
→
96 |

97 |
98 |
99 |
100 |
101 |
102 |
103 |

104 |
Cloudflare
Workers
105 |
[Workerd]
106 |
107 |
→
108 |

109 |
110 |
111 |
112 |
113 |
114 |

115 |
Bun
116 |
117 |
→
118 |

119 |
120 |
121 |
122 |
123 |
124 |
125 |

126 |
Fastly
Compute
@edge
127 |
128 |
→
129 |

130 |
131 |
132 |
133 |
134 |
135 |

136 |
Alibaba
Edge
Compute
137 |
138 |
→
139 |

140 |
141 |
142 |
143 |
144 |
145 |

148 |
llrt
149 |
150 |
→
151 |

155 |
156 | *experimental*
157 |
158 |
159 |
160 |
161 |

162 |

163 |
164 |
165 |
166 |
167 | So if my math is correct...
168 |
169 |
170 |
171 | 3 Browser JS Runtimes
172 |
177 |
178 |
179 |
180 | 6+ Server JS Runtimes
181 |
182 |

183 |

184 |

185 |

186 |

187 |

188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 | The next generation of server JS we write will be
198 | standards based.
199 |
200 |
201 |
202 |
203 | Yes, run it anywhere, but it also means we have
204 | interchangable + composable layers
205 |
206 |
207 |
208 |
209 | Should you care?
210 | maybe. You should care about the standards
211 |
212 |
213 |
214 | WHY
215 | Why do we have so many runtimes?
216 |
217 |
218 |
219 | Better
220 |
221 | - TS out of the Box
222 | - A push for Standard APIs
223 | - ESM Spec
224 | - Easy wins (dotenv, prompt, JSX, etc..)
225 | - A Joy to work with
226 |
227 |
228 |
229 |
230 | Faster
231 |
232 | - "cold starts"
233 | - "Rust"
234 | - "WASM"
235 | - "Async"
236 |
237 |
238 |
239 |
240 | Faster - Cheaper?
241 |
242 | - At scale, faster is a lot cheaper
243 | - CPU Time vs Wall Time
244 |
245 |
255 |
256 |
257 |
258 | Stronger
259 |
260 |
261 |
262 |
263 | Server Kinds
264 |
265 |
266 |
267 | Traditional VM / Long Running Server
268 |
269 | - Always running
270 | - Maintain Memory
271 | - Scaling up via Memory/CPU
272 | - Scaling up via more servers
273 |
274 |
275 |
276 |
277 |
278 | Serverless Functions
279 |
280 | - Only Run in short bursts when needed
281 | - Scale up by running more
282 | - Pay for what you need
283 |
284 |
285 |
286 |
287 |
288 | Edge Functions
289 |
290 | - Run closer to your user
291 | - Can run in-between / intercept requests
292 | Limited API
293 | - Not 100% node compat (close!)
294 |
295 |
296 |
297 |
298 |
299 |
300 | What's a poor dev to do? Support 6+ Runtimes?!
301 | well, ya. But also no.
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 | Web Standards
310 |
311 |
312 |

317 |
TC39
318 |
Async + Await, esm, const, arrow functions
319 |
320 |
321 |

326 |
W3C
327 |
WebRTC, Streams API, Web Components
328 |
329 |
330 |

335 |
WHATWG
336 |
Fetch, Service Workers, Resize Observer
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 | Browser JS is Server JS
355 | JS is JS
356 | We don't need different ways to do the same thing
357 | Let's look at some of those standards
358 |
359 |
360 |
361 | Fetch
362 | Web Request + Web Response are life
363 |
364 |
365 |
366 | In the Browser, We send Requests
367 |
368 |
369 |
370 | On the Server, we handle them!
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 | Node
380 | Not Native, But:
381 |
382 | Hono.js, H3, @whatwg-node/server, Fastify Plugin, Next.js Routes,
383 | Sveltekit, Astro + more
384 |
385 |
386 |
387 |
388 | Web Streams
389 | Blow Chunks as you have em
390 |
391 |
392 |
393 |
394 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 | Events!
417 | Listen for events on anything!
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 | Form Data
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 | Web Workers
440 |
441 | - Multi Threaded / Parallel
442 | - CPU intensive tasks
443 | - Non-blocking
444 |
445 |
446 |
447 |
463 |
464 |
465 | alert()
prompt()
confirm()
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
478 |
479 |
480 | Async
Local
Storage
481 | Really cool new API
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 | Developer Ecosystem
498 | The tooling is standardizing on standards
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 | unenv
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 | Deno, Bun, Cloudflare, Node
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 | Think of these as standards based Express that can run anywhere.
531 | HMR, Routing, Middlware, Caching, Web Sockets, Assets
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 | Vite + Nitro = Vinxi
547 |
548 |
549 |
550 | Build your own Framework
551 | Any JS LIb + Standard Server = Metaframework
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
565 |
566 |
567 |
568 | - ✅ Routing
569 | - ✅ RPC
570 | - ✅ Data Loaders
571 | - ✅ Middleware
572 | - ✅ API Endpoints
573 | - ✅ Server Rendering
574 | - ✅ Streaming
575 | - ✅ caching
576 | - + More.
577 |
578 |
579 |
580 |
581 | Tanstack Start
582 | Client: Vite, Tanstack Query, Tanstack Router
583 | Server: Vinxi → Nitro → H3 → srvx
584 |
585 |
586 |
587 | import { DOMParser, parseHTML } from 'linkedom/worker';
588 | JSDom Alternative. Works everywhere
589 |
590 |
591 |
592 | HTMLRewriter
593 |
594 | - Cloudflare Invented
595 | - Re-implemented everywhere
596 | - Not a standard
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
610 |
615 |
616 |
617 | So much more!
618 |
619 |
620 |
621 | This ins't write once work everywhere
622 | At least not yet...
623 |
624 |
625 |
626 |
627 | It is a set of standardized APIs and an
628 | ecosystem of tools that work together
629 |
630 |
631 |
632 |
633 |
639 |
640 |
641 | Future Server JS isn't about making it work everywhere.
642 |
643 |
644 | It's about building with standards, enjoying the huge
645 | ecosystem's best tools and having the choice for it to
646 | run anywhere.
647 |
648 |
649 |
650 |
651 | Thanks
652 | @wesbos
653 |
654 |
655 |
656 |
657 |
--------------------------------------------------------------------------------
/fonts/Ika_Compact_VAR.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesbos/next-gen-server-js/d468631b2e7b776f2571182a2ffb3210f611e606/fonts/Ika_Compact_VAR.woff2
--------------------------------------------------------------------------------
/fonts/Ika_VAR.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesbos/next-gen-server-js/d468631b2e7b776f2571182a2ffb3210f611e606/fonts/Ika_VAR.ttf
--------------------------------------------------------------------------------
/fonts/Ika_VAR.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesbos/next-gen-server-js/d468631b2e7b776f2571182a2ffb3210f611e606/fonts/Ika_VAR.woff2
--------------------------------------------------------------------------------
/fonts/Ika_VAR_Italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wesbos/next-gen-server-js/d468631b2e7b776f2571182a2ffb3210f611e606/fonts/Ika_VAR_Italic.woff2
--------------------------------------------------------------------------------
/go.ts:
--------------------------------------------------------------------------------
1 | // import { SessionsWave } from "./waves/wave";
2 | import FOG from "vanta/src/vanta.fog";
3 | // import TRUNK from "vanta/src/vanta.trunk";
4 | import TRUNK from "./vanta/trunk";
5 | // const x = new SessionsWave();
6 | // x.connect();
7 |
8 | // import svg from './icons/bun.svg?raw'
9 |
10 | // Get colors from body
11 | const body = document.querySelector("body");
12 | const color1 = getComputedStyle(document.documentElement).getPropertyValue(
13 | "--fogColor1"
14 | );
15 | const color3 = getComputedStyle(document.documentElement).getPropertyValue(
16 | "--fogColor3"
17 | );
18 | const color5 = getComputedStyle(document.documentElement).getPropertyValue(
19 | "--fogColor5"
20 | );
21 |
22 | const computedStyle = getComputedStyle(document.documentElement);
23 | const cssVariables = Object.fromEntries(
24 | Object.values(computedStyle)
25 | .filter((key) => key.startsWith(`--`))
26 | .map((key) => {
27 | return [key.replace(`--`, ''), computedStyle.getPropertyValue(key)];
28 | })
29 | );
30 |
31 | function hexToNumber(hex = '#ffc600') {
32 | return `0x${parseInt(hex.replace("#", ""), 16).toString(16)}`;
33 | }
34 |
35 | // FOG({
36 | // el: "#fog",
37 | // mouseControls: true,
38 | // touchControls: true,
39 | // gyroControls: false,
40 | // minHeight: 200.0,
41 | // minWidth: 200.0,
42 | // blurFactor: 0.8,
43 | // highlightColor: 0x6900ff,
44 | // midtoneColor: 0xff7ee9,
45 | // // lowlightColor: 0xbada55,
46 | // lowlightColor: 0xffc600,
47 | // baseColor: 0x2f52d9,
48 | // speed: 2.5,
49 | // });
50 |
51 |
52 | TRUNK({
53 | el: "#trunk",
54 | mouseControls: true,
55 | touchControls: true,
56 | gyroControls: false,
57 | minHeight: 500.0,
58 | minWidth: 500.0,
59 | scale: 2.0,
60 | scaleMobile: 1.0,
61 | // color: 0xff009e,
62 | color: 0x67655a,
63 | backgroundColor: `transparent`,
64 | spacing: 8.0,
65 | chaos: 1,
66 | });
67 |
68 | // Convert the canvas to an image
69 | async function waitForSelector