Dan Q
Hero Member ⚓︎
    
 

I have no idea what I am doing ⛺︎ My Room
RSS: 
Guild Memberships: Artifacts:
|
 |
« Reply #1 on: May 20, 2026 @574.78 » |
|
Iframes: An iframe could work, but has knock-on effects like being slower loading (more HTTP round-trips), much harder to make responsive (suitable for a wider variety of screen widths), and making more work to ensure that links in-iframes open in the right place (whole page, other subframe, or whatever). Personally, I'm not a fan of iframes, but I appreciate that they might be the least-bad solution for some people, some of the time.
Single pages: The gold standard from a user perspective is, of course, to deliver all the HTML the visitor needs in a single request. I've described some of the different ways to do this before, but the essence of it is that you either need big HTML files (and manage copy-pasting shared elements between them yourself) or some kind of process that makes those big HTML files from small pieces (e.g. using a Static Site Generator [SSG], or else something running on the server side like SSI [which is available on Nekoweb!], PHP, or similar). All of these are fantastic options, but not all of them are available to everybody, and some of them aren't suitable for some folks, which collectively might mean they're a no-go for you.
<embed-html> or similar: The limitations of the approaches above are what inspired me to create <embed-html>, which I think is a good middle-ground approach that gets some of the best of both worlds. Bear in mind that I'm biased! It introduces a JavaScript dependency, which is its weakest point, but there are ways by which you can partially-mitigate that. The short of it is that you load a JavaScript file and then add e.g. this code anywhere on a page, and it dynamically loads the "other" HTML snippet and includes it inside this one:<embed-html src="embedded-content.html" cache></embed-html>
It's simple and fast and I think more people should consider it as an alternative to iframes, where using an SSG or SSI isn't feasible. But again, I'm biased. Anyway: if you want to try it then it's got its own website to explain it or I'm happy to provide a more-concrete example. You can see a toy example of it working at embed-html.neocities.org where the menu bar is shared between all of the pages.
|