Live data from Hacker News

Building websites with lots of little HTML pages

blog.jim-nielsen.com

11–20 of 88 posts

Re: Building websites with lots of little HTML pages

#11
Old school web tech is the best. I still reach for multipart/form-data every day. Many of my web applications do not even have javascript.

I hope at some point the original pattern is re-discovered and made popular again because it would make things so much snappier:

1. Initial GET request from user's browser against index and maybe favicon.

2. Server provides static/dynamic HTML document w/ optional JS, all based upon any session state. In rare cases, JS is required for functionality (camera, microphone, etc.), but usually is just to enhance the UX around the document.

3. User clicks something. This POSTs the form to the server. The server takes the form elements, handles the request, and then as part of the same context returns the updated state as a new HTML document in the POST response body.

4. That's it. The web browser, if it is standards compliant, will then render the resulting response as the current document and the process repeats.

All of this can happen in a single round trip. Latency is NOT a viable argument against using form submissions. I don't think suffering window navigation events is a valid one either. At some point, that SPA will need to talk to the mothership. The longer it's been disconnected, the more likely it's gonna have a bad time.

The web only has to be hard if you want to make it hard. Arguments against this approach always sound resume-driven more than customer-driven. I bet you would find some incredibly shocking statistics regarding the % of developers who are currently even aware of this path.

Re: Building websites with lots of little HTML pages

#12
I love this approach. I just wish there was better tooling for HTML polyglot programming.

PHP got it right by embedding itself within "HTML" documents. React also got it right by inventing JSX. There's Go templ too. They all said "HTML deserves first class support".

Why can't this DX also be available for other general purpose PLs? I want my Python language server to detect that this or that string is HTML, and provide features accordingly. I don't want to keep bouncing between .py and .html files. Is this achievable?

Re: Building websites with lots of little HTML pages

#13
I'm doing something sort of similar now -- my research advisor was remarking on the messy state of all the scripts I use for numerical experiments (there's dozens of them, poorly commented, constantly changing and not well versioned, assumptions/purpose not documented etc).

Naturally I used that as an excuse to implement a framework for tracking the output of numerical experiments along with any generated assets and output and configuration details in a SQLite database. Then wrote a generator that pulls everything out of the database and builds a static HTML site.

Anyway I implemented a system of tags for grouping similar experiments. It's less polished and sophisticated than this, but it was quick to implement and feels suitably lightweight.

I'm realizing now that the SQLite database was a misstep, mainly for adding notes and metadata. So I'm planning to just use the filesystem instead so that one's raw experiment runs can be versioned as plaintext files (at the moment, just the static site is versioned)

But for now I need to get around to actually doing the experiments :(

Re: Building websites with lots of little HTML pages

#14
post #8
post #6

Views transitions are very useful in content-first websites. I've used them extensively when working on https://stack.lol Try and navigate through pages, or change the language, and you'll get these neat effects "for free". Frameworks like AstroJS also help a lot as they facilitate using view transitions.

I guess this is a matter of preference. I see when I click a link on stack.lol that the page header remains visible, but the rest of the page disappears (blanks to white) for a second before the next page appears. I prefer a seamless experience of seeing the next page immediately without a "white flash" first. For instance, if I am looking at a GitHub project page and I click the "Issues" button, in a fraction of a s…

Nice catch, thanks for the feedback.

I just enhanced a bit the implementation so that it flickers ...less.

Still looking for ways for this static implementation with view transitions to 100% persist the dark mode during transitions.

Edit: Fixed. Using a tiny bit of script[1] from the Astro documentation.

[1]: https://docs.astro.build/en/guides/view-transitions/#astrobe...

Re: Building websites with lots of little HTML pages

#15
post #12

I love this approach. I just wish there was better tooling for HTML polyglot programming. PHP got it right by embedding itself within "HTML" documents. React also got it right by inventing JSX. There's Go templ too. They all said "HTML deserves first class support". Why can't this DX also be available for other general purpose PLs? I want my Python language server to detect that this or that string is HTML, and provi…

Is this kinda what you want? https://peps.python.org/pep-0750/

(similar to template literals in JS)

You can also do something similar using f-strings, at the risk of content injection attacks.

Re: Building websites with lots of little HTML pages

#16
post #12

I love this approach. I just wish there was better tooling for HTML polyglot programming. PHP got it right by embedding itself within "HTML" documents. React also got it right by inventing JSX. There's Go templ too. They all said "HTML deserves first class support". Why can't this DX also be available for other general purpose PLs? I want my Python language server to detect that this or that string is HTML, and provi…

Slowly but surely...

PEP 750 (still a proposal) adds "t-strings" Python. They're a simple extension of f-strings that give developers access to the static and interpolated parts of the string before they get combined into a final string. They're Python's answer to JavaScript template literals.

This allows writing code like:

  user_name = current_user.user_name  # something user-supplied and potentially unsafe
  foo: HTMLElement = html(t"{user_name}")  # wouldn't be safe with f-strings
where `html` is a normal function that takes a `Template` as an instance, and can return whatever it likes -- say, an `HTMLElement` rather than a `str`.

If PEP 750 does get accepted, eventually one hopes the community will introduce formatting, type checking, and LSP smarts for common kinds of t-strings, like HTML and maybe SQL, etc.

Re: Building websites with lots of little HTML pages

#17

What were the arguments in favour of SPAs in the first place? I'm finding it interesting that most of the top HN submissions (by popularity) matching "single page app" are critical, not positive. First 15 follow, all but 5 are negative: - You probably don't need a single-page app ( https://journal.plausible.io/you-probably-dont-need-a-single... ) 816 points | 6 years ago | 499 comments - A single-page app is almost a…

That’s also because they were not called SPAs for the first 15 years of the web.

The very first technology for building “SPAs” was Java Applets. Corel released a web-based office suite already in 1997, and it was practically an applet for each app.

This was replaced by Flash because Macromedia did an incredible job of getting Flash Player preinstalled on every desktop computer. If you wanted to deliver a rich and seamless app-like web experience in 1999-2004, you used Flash. (It was mostly very primitive as a dev environment, but did a great job at vector motion graphics and video.)

The original progenitors of present-day SPAs are Microsoft Outlook for Web and Google Maps. Outlook invented the ubiquitous XmlHttpRequest object, and Google Maps became so popular that it coined “AJAX.”

Following these examples, people started building DOM-based JavaScript apps that loaded data asynchronously and built up views entirely in code. And that’s when they became modern SPAs.

(There was also Silverlight and some other technologies that vied for the rich web app crown, but JS/DOM carried the day especially when iPhone happened and wouldn’t support anything else.)

Re: Building websites with lots of little HTML pages

#18
post #6

Views transitions are very useful in content-first websites. I've used them extensively when working on https://stack.lol Try and navigate through pages, or change the language, and you'll get these neat effects "for free". Frameworks like AstroJS also help a lot as they facilitate using view transitions.

Sorry to report this doesn’t work well on mobile Safari.

Tapping one of the items in the list causes mayhem.

Going ‘back’ causes stuff to flicker all over the screen.

Re: Building websites with lots of little HTML pages

#19
post #11

Old school web tech is the best. I still reach for multipart/form-data every day. Many of my web applications do not even have javascript. I hope at some point the original pattern is re-discovered and made popular again because it would make things so much snappier: 1. Initial GET request from user's browser against index and maybe favicon. 2. Server provides static/dynamic HTML document w/ optional JS, all based up…

I'm increasingly getting to this point as well. I think modern webtech is incredible in many ways, and if properly used could be pretty great but overall and for the most part we are pretty terrible at it. I've started to dread using SPAs because I know it's going to be sluggish and load megabytes of junk, and will still require frequent page reloads when clicking stuff Even though ostensibly it should not.

There's an exceptional beauty in a simple and lightweight website that is just a load and done. I've started doing more with Phoenix and Alpine for the little bits of client-side functionality required, and have been very pleased with it. The most interesting part though, is that users have also been very pleased. They can't explain why in technical terms, but they know it feels better.

Re: Building websites with lots of little HTML pages

#20
post #2

This is brilliant. Instead of a single page app (SPA), you can almost picture the connections between all these little .html pages as some sort of web.

One spanning the world, perhaps. Even ... widely.

It's a great idea, but I don't see it working long-term. At some point I suspect big tech will aggregate and centralize and kill off these little sites. They may even start implementing technology that locks them down so that you can only visit them with approved devices. Hopefully Netscape refuses to go along with it, though I do worry about their business model's long term viability.
Post reply on HN