Live data from Hacker News

Why can't HTML alone do includes?

frontendmasters.com

311–320 of 367 posts

Re: Why can't HTML alone do includes?

#311
post #161

Earlier quoted context omitted.

> Why not have a simple client side method for this? Like writing a line of js?

A block of in-line JavaScript stops the renderer until it runs because its output cannot be determined before it completes.

> A block of in-line JavaScript stops the renderer until it runs because its output cannot be determined before it completes.

I do it in a way that doesn't stop the renderer.

Re: Why can't HTML alone do includes?

#312

Earlier quoted context omitted.

We also had a brief detour into XML with XHTML, and XML has XInclude, although it's not a required feature.

It's too bad we didn't go down the XHTML/semantic web route twenty years ago. Strict documents, reusable types, microformats, etc. would have put search into the hands of the masses rather than kept it in Google's unique domain. The web would have been more composible and P2P. We'd have been able to slurp first class article content, comments, contact details, factual information, addresses, etc., and built a wealth…

As a programmer, I really liked XHTML because it meant I could use a regular XML parser/writer to work with it. Such components can be made small and efficient if you don't need the more advanced features of XML (ex: schemas), on the level of JSON. I remember an app I wrote that had a "print" feature that worked by generating an HTML document. We made it XHTML, and used the XML library we already used elsewhere to generate the document. Much more reliable than concatenating strings (hello injections!) and no need for an additional dependency.

In addition, we used XSLT quite a bit too. It is nice being able to open your XML data files in a web browser and having it nicely formatted without any external software. All you needed was a link to the style sheet.

Re: Why can't HTML alone do includes?

#313
Kind of serious question. Do we have any alternatives to html? If not, why? It’s essentially all html. Yes, browser will render svg/pdf/md and so on, but as far as I can tell, it’s not what I consider "real web" (links to other documents, support for styling, shared resources, scripting, and so on ).

I would have loved for there to be a json based format, or perhaps yaml, as an alternative to the xml- based stuff we have today.

Re: Why can't HTML alone do includes?

#314
post #34

"Includes" functionality is considered to be server-side, i.e. handled outside of the web browser. HTML is client-side, and really just a markup syntax, not a programming language. As the article says, the problem is a solved one. The "includes" issue is how every web design student learns about PHP. In most CMSes, "includes" become "template partials" and are one of the first things explained in the documentation. T…

> As the article says, the problem is a solved one.

It's "solved" only in the sense that you need to use a programming language on the server to "solve" it. If all you are doing is static pages, it's most definitely not solved.

Re: Why can't HTML alone do includes?

#315

Earlier quoted context omitted.

We also had a brief detour into XML with XHTML, and XML has XInclude, although it's not a required feature.

It's too bad we didn't go down the XHTML/semantic web route twenty years ago. Strict documents, reusable types, microformats, etc. would have put search into the hands of the masses rather than kept it in Google's unique domain. The web would have been more composible and P2P. We'd have been able to slurp first class article content, comments, contact details, factual information, addresses, etc., and built a wealth…

That’s not how the history went at all. When I worked at an internet co in the late 1990s (ie pre google’s dominance) SGML was a minority interest back then. We used to try to sell clients on an intranet based on SGML because of the flexibility etc and there was little interest and sloppy markup and incorrect html was very much the norm on the web back then (pre chrome etc)

Re: Why can't HTML alone do includes?

#316
post #197

HTML was historically an application of SGML, and SGML could do includes. You could define a new "entity", and if you created a "system" entity, you could refer to it later and have it substituted in. ]> .... &myheader; SGML is complex, so various efforts were made to simplify HTML, and that's one of the capabilities that was dropped along the way.

Neat reference, going to look into that. The tag appears to include/embed other html pages. An embedded HTML page: https://www.w3schools.com/tags/tag_object.asp

Yeah, that is just a crappier version of HTML Frames [1]

1 - https://en.m.wikipedia.org/wiki/Frame_(World_Wide_Web)

Re: Why can't HTML alone do includes?

#317
post #197

Earlier quoted context omitted.

Neat reference, going to look into that. The tag appears to include/embed other html pages. An embedded HTML page: https://www.w3schools.com/tags/tag_object.asp

Yeah, that is just a crappier version of HTML Frames [1] 1 - https://en.m.wikipedia.org/wiki/Frame_(World_Wide_Web)

I don’t disagree, the premise of the article seems to be unaware, it’s entirely possible to us html alone to do includes. :)

Some might argue react is over abstracted or over engineered to do the same.

Interpretation and preference is different than if it’s possible

Re: Why can't HTML alone do includes?

#318
post #197

Earlier quoted context omitted.

Neat reference, going to look into that. The tag appears to include/embed other html pages. An embedded HTML page: https://www.w3schools.com/tags/tag_object.asp

used like this is just a poor iframe in a much shakier spot in the standards, mostly for backwards compatibility. Like iframe, it "includes" a full subdocument as a block element, which isn't quite what the OP is hinting at.

It’s an option built into html.

The OP doesn’t need to hint.

Re: Why can't HTML alone do includes?

#319

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.

I think true transclusion would be more than that.

In Xanadu you could transclude just an excerpt from one document into another document.

If you wanted to do this with HTML you need an answer for the CSS. In any particular case you can solve it, making judgements about which attributes should be consistent between the host document, the guest document and the guest-embedded-in-host. The general case, however, is unclear.

For a straightforward tag the guest document is engineered to live inside the CSS environment (descendant of the 3rd div child of a p that has class ".rodney") that the host puts it in.

Another straightforward answer is the Shadow DOM which, for the most part, lets the guest style itself without affecting the rest of the document. I think in that case the host can still put some styles in to patch the guest.

Re: Why can't HTML alone do includes?

#320
post #236

Earlier quoted context omitted.

used like this is just a poor iframe in a much shakier spot in the standards, mostly for backwards compatibility. Like iframe, it "includes" a full subdocument as a block element, which isn't quite what the OP is hinting at.

Sound like it's good enough for headers and footers, which is 80% of what people need.

Whether it’s good enough or not it does exist and everyone can decide if it works for them.

I’d probably explore WebComponents, but wanting the height of JavaScript without JavaScript..

Post reply on HN