> We’ve got , which technically is a pure HTML solution, but they are bad for overall performance, accessibility, and generally extremely awkward here What does this mean? This is a pure HTML solution, not just "technically" but in reality. (And before iframe there were frames and frameset). Just because the author doesn't like them don't make them non-existent.
The real problem with iframes is that their size is set by the parent document only. They would be a lot more useful if we could write e.g. so the height of the iframe element is set by the abc.html document instead of the parent document.
Why can't HTML alone do includes?
81–90 of 367 posts
Re: Why can't HTML alone do includes?
#82Earlier quoted context omitted.
Well said this is many students' intro to PHP. Why not ` ` though? Some content is already loaded asynchronously such as images, content below the fold etc. > HTML is really just a markup syntax, not a programming language flamebait detected :) It's a declarative language, interpreted by each browser engine separately.
What's the ML in HTML stand for? I think that's probably the crux of the argument. Are we gonna evolve it past its name?
, , , etc.
Or create a new tag that's a noun like fragment, page, document, subdoc or something.
Surely that's no less markup than svg, img, script, video, iframe, and what not.
Re: Why can't HTML alone do includes?
#83Earlier quoted context omitted.
HTML is a markup language, not a programming language. It's like asking why Markdown can't handle includes. Some Markdown editors support them (just like some server-side tools do for HTML), but not all.
This isn’t programming. It’s transclusion[0]. Essentially, iframes and images are already forms of transclusion, so why not transclude html and have the iframe expand to fit the content? As I wrote that, I realized there could be cumulative layout shift, so that’s an argument against. To avoid that, the browser would have to download all transcluded content before rendering. In the past, this would have been a dealbr…
Re: Why can't HTML alone do includes?
#84I'm not an expert on this but IMO, from a language point of view, HTML is a markup language, it 'must' have no logic or processing. It is there to structure the information not to dynamically change it. Nor even to display it nicely. The logic is performed elsewhere. If you were to have includes directly in HTML, it means that browsers must implement logic for HTML. So it is not 'just' a parser anymore. Imagine for e…
> from a language point of view, HTML is a markup language, it 'must' have no logic or processing. Client-side includes are not "processing". HTML already has frames and iframes which do this, just in a worse way, so we'd be better off.
(yes in my view I interpret includes as a basic procedure)
[1] http://www.info.ucl.ac.be/people/PVR/paradigmsDIAGRAMeng201....
Re: Why can't HTML alone do includes?
#85This was the rabbit hole that I started down in the late 90s and still haven’t come out of. I was the webmaster of the Analog Science Fiction website and I was building tons of static pages, each with the same header and side bar. It drove me nuts. So I did some research and found out about Apache server side includes. Woo hoo! Keeping it DRY (before I knew DRY was a thing). Yeah, we’ve been solving this over and ove…
I’m sure some purist argument has driven this somewhere.
Re: Why can't HTML alone do includes?
#86Earlier quoted context omitted.
The real problem with iframes is that their size is set by the parent document only. They would be a lot more useful if we could write e.g. so the height of the iframe element is set by the abc.html document instead of the parent document.
You can achieve that with js in the parent document.
Re: Why can't HTML alone do includes?
#87 customElements.define('html-import', class extends HTMLElement {
connectedCallback() {
const href = this.getAttribute('href')
const fetch = new XMLHttpRequest()
fetch.responseType = 'document'
fetch.addEventListener('readystatechange', (function onfetch(e) {
if (fetch.readyState !== XMLHttpRequest.DONE) return
const document = fetch.response.querySelector('body') ?? fetch.response
this.replaceWith(document)
}).bind(this))
fetch.open('GET', href)
fetch.send()
}
})Re: Why can't HTML alone do includes?
#88Earlier quoted context omitted.
Yep, and this can be used to e.g. make a basically static site template and then do an include for `userdata.xml` to decorate your page with the logged in user's info (e.g. on HN, adding your username in the top right, highlighting your comments and showing the edit/delete buttons, etc.). You can for example include into a variable ` ` and then use it in xpath expressions like `$myinfo/user/@id`. Extremely simple, go…
> if resources were devoted to this You'd better not jinx it: XSL support seems like just the sort of thing browser devs would want to tear out in the name of reducing attack surface. They already dislike the better-known SVG and never add any new features to it. I often worry that the status quo persists only because they haven't really thought about it in the last 20 years.
Re: Why can't HTML alone do includes?
#89Earlier quoted context omitted.
You can message the page dimensions to the parent. To do it x domain you can load the same url into the parent with the height in the #location hash. It won't refresh that way.
I know it’s possible to work around it, but that’s not the point. This is such a common use case that it seems worthwhile to pave the cowpath. We’ve paved a lot of cowpaths that are far less trodden than this one. This is practically a cow superhighway. We’ve built an industry around solving this problem. What if, for some basic web publishing use cases, we could replace a complex web framework with one new tag?
Re: Why can't HTML alone do includes?
#90Earlier quoted context omitted.
Iframe is stuck in a rectangular box. It's not really suitable for things like site wide headers, footers and menus.
While I get your point, headers and footers and menus tend to all live within rectangular boxes.