All too often we developers are building websites using powerful computers over fibre Internet. What seems fast enough for us, is dreadfully slow for the vast majority of our users. In the worst case, imagine a person with a 10-year-old phone nowhere near a CDN edge node loading a bloated webapp over 3G. They wouldn't even be able to load the website let alone use it.
We need to aggressively fight against webapp bloat.
Vite has native support for multi-page applications. Think of each sub-folder as its own independent single-page application. A normal
<a href=...> is used to navigate between pages.
index.html for each page.
React.createElement and then rendered with
We can kill two birds with one stone. We can solve the extra
Sending templated HTML snippets from the backend? What are we building this with, Perl CGI scripts? Well actually...
For example, let's say we are building a todo app. The initial render is of an empty list.
The server returns HTML snippets with
id. The form is sent back to clear the value and the new todo is added to the list.
This idea of sending HTML snippets to the frontend isn't new, it just hasn't been executed well yet. At its most refined, it would probably look like HATEOAS. For the best-known implementation of this idea, check out htmx, but it's rough at the edges.
This is an extreme idea and likely a bad fit unless one has a tight bandwidth budget.
Do you want to sweat the bytes? You're in luck, Battlefy is hiring.