Live data from Hacker News

Why can't HTML alone do includes?

frontendmasters.com

41–50 of 367 posts

Re: Why can't HTML alone do includes?

#42
I'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 example that I create an infinite loop of includes, who is responsible to limit me? How to ensure that all other browsers implement it in the same way?

What happens if I perform an injection from another website? Then we start to have cors policy management to write. (iframes were bad for this)

Now imagine using Javascript I inject an include somewhere, should the website reload in some way? So we have a dynamic DOM in HTML?

Re: Why can't HTML alone do includes?

#43
The name of this feature is transclusion.

https://en.wikipedia.org/wiki/Transclusion

It was part of Project Xanadu, and originally considered to be an important feature of hypertext.

Notably, mediawiki uses transclusion extensively. It sometimes feels like the wiki is the truest form of hypertext.

Re: Why can't HTML alone do includes?

#44
post #14

Iframes, while not perfect, are pretty close though...

Interaction between elements in different iframes is very restricted.

IIRC, you can communicate entire JSON objects between an iframe and it's host frame with PostMessage.

The host can then act as a server for the iframe client, even updating it's state or DOM in response to a message from the iframe.

Re: Why can't HTML alone do includes?

#45

Isn't this what proper framesets (not iframes) were supposed to do a long time ago (HTML 4?). At least they autoexpanded just fine and the user could even adjust the size to their preference. There was a lot of criticism for frames [1] but still they were successfully deployed for useful stuff like Java API documentation [2]. In my opinion the whole thing didn't stay mostly because of too little flexibility for desig…

Issue with frame set was way more fundamental: No deep linking, thus people coming via bookmarks or Google (or predecessor) were left on a page without navigation, which people then tried working around with JavaScript, which never gave it a good experience.

Re: Why can't HTML alone do includes?

#47
post #36
post #17

This 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…

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?

#48
post #33

> 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.

No way. You can't make a decent single web page by iframing a bunch of components together.

Re: Why can't HTML alone do includes?

#49

Isn't this what proper framesets (not iframes) were supposed to do a long time ago (HTML 4?). At least they autoexpanded just fine and the user could even adjust the size to their preference. There was a lot of criticism for frames [1] but still they were successfully deployed for useful stuff like Java API documentation [2]. In my opinion the whole thing didn't stay mostly because of too little flexibility for desig…

Issue with frame set was way more fundamental: No deep linking, thus people coming via bookmarks or Google (or predecessor) were left on a page without navigation, which people then tried working around with JavaScript, which never gave it a good experience.

Nowdays it is sometimes the other way around: Pages are all JavaScript so no good experience in the first place. I have encountered difficulty trying to get a proper “link” to something multiple times. Also, given that Browsers love to reduce/hide the address bar I wonder if it is really still that important a feature.

Of course "back then" this was an important feature and one of the reasons for getting rid of frames :)

Re: Why can't HTML alone do includes?

#50

So, HTML did have includes and they fell out of favor. The actual term include is an XML feature and it’s that feature the article is hoping for. HTML had an alternate approach that came into existence before XML. That approach was frames. Frames did much more than XML includes and so HTML never gained that feature. Frames lost favor due to misuse, security, accessibility, and variety of other concerns.

Unlike Framesets I think XML includes were never really supported in many browsers (or even any major browsers)?

I still like to use them occasionally but it incurs a "compilation" step to evaluate them prior to handing the result of this compilation to the users/browsers.

Post reply on HN