Skip to content

Commit 5f6eebd

Browse files
committed
fix: grammar
1 parent 74cd4dd commit 5f6eebd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/blog/optimizing-compile-times/index.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Yikes.
3131

3232
You can see a loooong chain of unparallelizable compilations from us implementing live reload by using, uh, an entire web ecosystem. Well, let's think. What exactly did these dependencies do, anyway? They spun up a web server and reloaded the page when Typst compilation finished.
3333

34-
If you aren't familiar, I refer you to the Rust Book for how a tutorial stepping through a #link("https://doc.rust-lang.org/book/ch21-00-final-project-a-web-server.html")[dead-simple web server]. Since `cts` just serves static assets, I can also just write one myself with manual TCP connections and HTTP messages, and it _probably_ won't be an issue.#footnote[Come #link("https://github.com/wade-cheng/compile-typst-site/issues")[holler] at me if it is.]
34+
If you aren't familiar, I refer you to the Rust Book for a tutorial stepping through a #link("https://doc.rust-lang.org/book/ch21-00-final-project-a-web-server.html")[dead-simple web server]. Since `cts` just serves static assets, I can also just write one myself with manual TCP connections and HTTP messages, and it _probably_ won't be an issue.#footnote[Come #link("https://github.com/wade-cheng/compile-typst-site/issues")[holler] at me if it is.]
3535

3636
Now, how does reloading a web server work? I knew `tower-livereload` injected code, but a bit of further digging led to #link("https://emnudge.dev/notes/live-reload/"), which alongside the HTTP spec and the Rust Book web server tutorial, informed the basis of my implementation. As it turns out, we control the web server code, and the web server tells the browser what to render, so we can easily inject any (JavaScript) code we need to run on that front---just insert it right before responding to the client. Conceptually, that code just says "any time I get notified, reload the page." We wait for notifications via JavaScript's #link("https://developer.mozilla.org/en-US/docs/Web/API/EventSource")[`EventSource`], which opens a connection to a server and gets pinged every time that server sends a message back. The specific spec says something along the following: when a server receives a request from an `EventSource`, it should respond `OK` with the mime-type `text/event-stream`. I sent the rust byte string:
3737

0 commit comments

Comments
 (0)